Hello, I have a doubt about creating a 301 redirect on a ecommerce website with apache and .htaccess. The ecommerce structure is this: home home/cat1 home/cat1/cat2 home/cat1/cat2/cat3 home/cat1/cat2/cat3/product1 home/cat1/cat2/cat3/product2 .... I simply want to redirect all "product pages" to theirs category pages. If I could make it manually I would insert in the .htaccess file: redirect 301 /cat1/cat2/cat3/product1 www.home.com/cat1/cat2/cat3 But I can't do that for 15000 pages for every category. Is there anything that could automatically redirect the "product pages" to their category? Let me know, Thank you
This line is an infinite loop. redirect 301 /cat1/cat2/cat3/product1 www.home.com/cat1/cat2/cat3/product1 You are redirecting a page to itself. Am I missing something? /cat1/cat2/cat3/product1 is the directory structure and www.home.com/cat1/cat2/cat3/product1 is the url. Can you give a more accurate example?
Hello, I made a mistake. I didn't want to write this: but this one: Sorry for the treuble. I just correct my original post. Thank you for your answer.
A quick and dirty solution depending on the category structure is to write a redirect fo each cat. Note that your products match the (.*) Try this code: RewriteEngine on RewriteBase / RewriteRule ^cat1/cat2/cat3/(.*) http://www.home.com/cat1/cat2/cat3/ [R=301,L] Code (markup): I am not an expert, so try it before deploy it. If the cat structure is more complicated you might need a more complex model. Let us know if it worked for you.