Caylean
Caylean

Reputation: 197

Remove /feed from Postings in Wordpress

I have again a small Question about Redirects.

My wordpress Blogs is quite new and I really like it, but I found in Google and other 'SEO' tools that for some reason my https://www.domain.tld/posting-name/feed URL's get read out. Never saw that before. Now I wish to redirect all feed urls of this kind.

https://www.domain.tld/posting-1-name/feed redirects to https://www.domain.tld/posting-1-name/ https://www.domain.tld/posting-2-name/feed redirects to https://www.domain.tld/posting-2-name/ https://www.domain.tld/posting-3-name/feed redirects to https://www.domain.tld/posting-3-name/

How would i do that?

Doing it manually would be a piece of cake

Redirect 301 /posting-1-name/feed https://www.domain.tld/posting-1-name/
Redirect 301 /posting-2-name/feed https://www.domain.tld/posting-2-name/
Redirect 301 /posting-3-name/feed https://www.domain.tld/posting-3-name/

But as this is a Blog, there are about to come every week 4-8 new Postings at least and I can't simply add the needed lines every time I create a new Posting.

There must be something in mod_rewrite or how its call, doesn't it?

Please say "Sure $&!&, just use this line of code. If you would have know how to call this kind of redirect you could have found it in 1 Minute of googling" .... but as I habe no idea of how to call it... there was nothing to be found.. and the snippets for the functions.php were all only intended to remove links TO feeds inside the code the head/footer.

Thanks guys.

Upvotes: 0

Views: 900

Answers (1)

olegsv
olegsv

Reputation: 1462

RewriteEngine On
RewriteRule ^(.+)/feed$ http://yourdomain.tld/$1 [R=301,L]

This code will redirect any problematic posting URL.

Another solution is to use RedirectMatch :

RedirectMatch 301 /(.+)/feed http://yourdomain.tld/$1

Upvotes: 1

Related Questions