I'm looking at changing the products URLs' structure on a Prestashop (v1.5) website. This process is quite straight-forward and it can be done instantly through the corresponding admin panel.

The thing is, many of the products are indexed on Google (and other search engines too I'm guessing) so I'd like to 301-redirect the old links until the indexers update themselves with the new URLs. I'm guessing it's probably the safest way to handle the change: avoiding 404s and duplicates.

Since I have hundreds of products in this shop, I'm not looking to redirect them one by one, obviously. But then I don't really know how to manage the structure change properly within an htaccess file.

At the moment, I'm using the default Prestashop structure:


Which produces the following links:


I'm now looking at changing it to the following structure (which I think might be more efficient because you can find the same words on category and product names):


Which would produce this kind of link:


But now I don't really know how to handle the change, if it can even be done easily?

And without any changes, the old links aren't automatically redirected to the new ones.

1 Answer 1


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.

  • Well, that was easy, feeling kinda dumb now... :) Thanks a lot, it works!
    – shroom
    Commented Oct 29, 2014 at 16:15
  • Hi can you please confirm how to implement this in .htaccess where to add this line RedirectMatch permanent /[^/]+/([0-9]+)-(.*)-([0-9]+)\.html$ /$2-$1-$3
    – user53529
    Commented Jun 24, 2015 at 10:25
  • It is best to add it at the top. That way it takes precedence over other rules. Commented Jun 24, 2015 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.