Htaccess remove string from url

We have currently moved our site to a new server, but have reformatted our menu item links.

The previous ones were:

www.example.com/products/module-home/something.html

      

and now they:

www.example.com/products/something.html

      

What I would like to do is if the user tried to visit the page that contains module-home

in the url, it will just delete it and redirect to the url without it. What would be the best rule for this RewriteRule?

RewriteRule ^module-home/(.*)$ /$1 [L,R=301]

      

I know Joomla has its own redirect manager built into the backend, but from a performance point of view, I think modifying the file .htaccess

would be better, however if I am wrong, believe me.

+3


source to share


1 answer


Assuming your htaccess is in the root folder, you can put this rule in the first position (right after the line RewriteEngine on

or RewriteBase

)



RewriteRule ^([^/]+)/module-home/?(.*)$ /$1/$2 [R=301,L]

      

+3


source







All Articles