admin管理员组

文章数量:1122832

I have permalinks with a .html suffix for backwards compatibility. I see in the Google Search console that my posts are getting /feed added, and as a result I get these URLs that 404:

.html/feed

How can I remove /feed from the end of the URL for single posts to clean up the 404's, but not remove the overall feed URL that is for the entire site, example/feed?

I have permalinks with a .html suffix for backwards compatibility. I see in the Google Search console that my posts are getting /feed added, and as a result I get these URLs that 404:

https://example.com/2024/08/post-name.html/feed

How can I remove /feed from the end of the URL for single posts to clean up the 404's, but not remove the overall feed URL that is for the entire site, example.com/feed?

Share Improve this question edited Sep 2, 2024 at 15:01 BlueDogRanch asked Aug 28, 2024 at 16:39 BlueDogRanchBlueDogRanch 1925 silver badges25 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can achieve this by adding the code to .htaccess file of your apache server.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/([0-9]{4})/([0-9]{2})/([^/]+)\.html/feed/?$ [NC]
RewriteRule ^ /%1/%2/%3.html [R=301,L]

The given code will helps you in set up a redirect so that any request to a post URL with /feed appended will be redirected to the original post URL without the /feed suffix.

Using this way, the incorrect URLs won't result in 404 errors.

本文标签: Remove trailing feed from permalinks that use a html suffix