301 redirect folder url to root url using htaccess

Our SEO department recently tweaked the URLs of a client website in order to improve the search engine rankings. The change was minor and they just removed a category path from the URL which shortened the actual length of the URL. There was one problem. The website was already indexed in Google and even though the change was minimal the effect was on hundreds of URLs. When any one clicked on the old URL indexed in Google the 404 page showed up which was a Big NO NO if you are some one managing a website having more than 50,000 GBP of sales.

The solution was an addition of one line in the .htaccess file which would automatically redirect the visitor from the old URL to the new URL.

I added the following line which resolved the problem.

RedirectMatch webman/(.*)$ http://www.adeelsarfaraz.com/$1 [R=301,L]

Please note that the above is an example. You can replace the webman to your path name and the domain name to the relevant domain name.


Leave a Comment