How to do this with regular expression?
Old -> New
http://www.example.com/cat1/cat2/cat3/tool-model-10 -> http://www.example.com/tool/tool-model-10
http://www.example.com/cat1/cat2/cat4/tool-model-11 -> http://www.example.com/tool/tool-model-11
http://www.example.com/cat1/cat2/tool-model-12 -> http://www.example.com/tool/tool-model-12
http://www.example.com/cat5/cat6/tool-model-13 -> http://www.example.com/tool/tool-model-13
http://www.example.com/cat7/tool-model-14 -> http://www.example.com/tool/tool-model-14
I've tried this:
Redirect 301 /cat1/cat2/cat3/tool-model-10 http://www.example.com/tool/tool-model-10
Redirect 301 /cat1/cat2/cat4/tool-model-11 http://www.example.com/tool/tool-model-11
Redirect 301 /cat1/cat2/tool-model-12 http://www.example.com/tool/tool-model-12
Redirect 301 /cat5/cat6/tool-model-13 http://www.example.com/tool/tool-model-13
Redirect 301 /cat7/tool-model-14 http://www.example.com/tool/tool-model-14
I understand that logiс should be:
- divide URL string on 2 strings: 1 and 2
- If first URL string 1 contains
tool-model-at the end AND does not containtoolcatalog at the beginning then make redirect tohttp://www.example.com/tool/tool-model-PLUS two digits (string 2).