Reputation: 31
after I have upgraded my site I see that once I go live with new version some parts of the website URLs will not be redirected for gallery, blogs and files because of new structure. And there is no way fixing it within the CMS. So my goal is to use htaccess redirects.
I wonder do any of you know any .htaccess rewrite tricks to make such redirects possible?
website.com/forums/blogs/ into website.com/blogs/
website.com/forums/gallery/ into website.com/gallery/
website.com/forums/files/ into website.com/files/
I actually need the part forums dropped from the URL only and ONLY when the address is going for forums+blogs/gallery/files. Don't want to loose that google traffic.
So for example
website.com/forums/blogs/entry123/my-dog/ is redirected to
website.com/blogs/entry123/my-dog/
BUT
website.com/forums/topic/my-dog/
is left alone and working just like before because the following subfolder is neither blogs or gallery or files.
So far I came up only with such a rule but it removes forums part from every URL which is not the goal. I can't think of a way to add en exclusion to make it work only if it is followed by these 3 words.
RewriteRule ^forums/(.*)$ /$1 [L,NC,R]
Upvotes: 1
Views: 19
Reputation: 31
It was
RewriteRule ^forums/(blogs|gallery|files)/(.*)$ /$1/$2 [L,R=301]
Upvotes: 1