Hello. I ask for help, because with .htaccess I am not strong, I can do no more elementary tasks, so I’ll warn you in advance that I’m looking for a ready-made solution or a smart article to solve my problem.

And so, the point is that there is a catalog of products on the site:

URN

/catalog/phone-new /catalog/pc-new /catalog/mouse-new /ctalog/keyboard-new

and so on, there are a lot of them, they all transferred to a new address:

/catalog/phone /catalog/pc /catalog/mouse /ctalog/keyboard And you need to write a 301 redirect, the same situation with goods:

/catalog/phone/iphone /catalog/phone/blackberry /catalog/pc/macbook /catalog/pc/hp /catalog/mouse/razer /catalog/mouse/logitech

need to:

/catalog/iphone /catalog/blackberry /catalog/macbook /catalog/hp /catalog/razer /catalog/logitech

Thank you in advance.

  • and some kind of system exists? for example, in the second case it looks like you just need to remove the second level after / catalog / - splash58
  • @ splash58 that's right, you just need to remove the catalog - k0mar
  • RewriteRule ^catalog/.+/(.+)$ /catalog/$1 [R=301] - splash58
  • @ splash58 write the answer, I'll give you a poke and I will accept the answer, thanks :) - k0mar
  • wrote. glad that helped - splash58

1 answer 1

in the second case, to remove the second level is enough of such a rule

 RewriteRule ^catalog/.+/(.+)$ /catalog/$1 [R=301] 
  • Thanks, machine gun, works :) - k0mar