Apologies if this has been covered before, but I’ve searched high and low for a solution to my problem but haven’t come across anything yet. My problem is that I’m getting 301 loops…nothing new there I know. I’m using Prestashop which by default puts a category ID before the name of the category in links – for example: http://www.example.com/shop/5-laptops. I have changed the PHP code so that this no longer happens and the links are now of the form http://www.example.com/shop/laptops. However, for search engine reasons, I still want the old links (containing the category ID) to be active. The original link (e.g. http://www.example.com/shop/5-laptops) is itself a rewrite to something like http://www.example.com/shop/category.php?id_category=5 which I believe is achieved by the following two lines in the .htaccess file (generated automatically by Prestashop):
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]*(/[a-zA-Z0-9-]*)+ /shop/category.php?id_category=$1&noredirect=1 [QSA,L]
RewriteRule ^([0-9]+)\-[a-zA-Z0-9-]* /shop/category.php?id_category=$1 [QSA,L]
So, I need http://www.example.com/shop/5-laptops and http://www.example.com/shop/laptops to link to http://www.example.com/shop/category.php?id_category=5 and I also need http://www.example.com/shop/category.php?id_category=5 to link to http://www.example.com/shop/laptops and therein lies my problem. I cannot find a way of achieving this without getting stuck in a loop.
I can get a redirect to take place by adding the following line (before the 2 lines above):
RewriteRule ^laptops$ /shop/category.php?id_category=5 [QSA,L]
but as soon as I add R=301, I get stuck in a loop.
I think my brain is also stuck in a loop now so any help would be greatly appreciated.