Reputation: 19733
We've currently moved our site to a new server but re-formatted the menu item links.
The previous ones were:
www.example.com/products/module-home/something.html
and now they are:
www.example.com/products/something.html
What I would like to do is, if a user tried to visit a page which contains module-home
in the URL, it will simply remove it and redirect them to the URL without it. Would the following RewriteRule rule be the best approach for this?
RewriteRule ^module-home/(.*)$ /$1 [L,R=301]
I know Joomla has it's own redirect manager built into the backend, however performance wise, I think modifying the .htaccess
file would be better, however correct me if I'm wrong.
Upvotes: 8
Views: 10120
Reputation: 19016
Assuming your htaccess is in the root folder, you can put this rule in first position (right after RewriteEngine on
or RewriteBase
line)
RewriteRule ^([^/]+)/module-home/?(.*)$ /$1/$2 [R=301,L]
Upvotes: 7