Jump to content

How to create a url redirect for my entire shop after changing url structure


Recommended Posts

I am planning to change the product page url structure of my website on PS1.6

Currently i am using route to product as

{categories:/}{id}-{rewrite}.html

which creates url as : example.com/category/sub-category/product-name.html

I wish to change this to

{id}-{rewrite}.html

which will create url as : example.com/product-name.html

 

As the category & sub-category & product name have some common words the urls are not good for SEO. Now beacuse my product pages are already indexed on google with the existing route

 

HOW can i redirect my existing URL structure to the new URL structure once I change the product route to avoid 404????

 

I found a solution that suggest the following

 

Using a RedirectMatch directive from mod_alias in your .htaccess file should do the trick:

RedirectMatch permanent /[^/]+/([0-9]+)-(.*)-([0-9]+)\.html$ /$2-$1-$3

This pulls out the matching parts of your old URLs and redirects them to the new format.

 

But I am not sure how to implement it in .htaccess, where exactly this line needs to be added and do I need to add some more syntax as well..????

 

 

Link to comment
Share on other sites

×
×
  • Create New...