I have three RewriteRules I am trying to implement but I cannot get all 3 to work together:
RewriteRule ^products$ http://%{SERVER_NAME}/en_ca/products [L,R=301]
RewriteRule ^products/(.*)$ http://%{SERVER_NAME}/en_ca/$1 [L,R=301]
RewriteRule ^products/(.*)/(.*)$ http://%{SERVER_NAME}/en_ca/$2 [L,R=301]
What I am trying to achieve is as follows:
- www.domain.com/products > www.domain.com/en_ca/products
- www.domain.com/products/product-name > www.domain.com/en_ca/product-name
- www.domain.com/products/cat/product-name > www.domain.com/en_ca/product-name
I can get 1 & 2 working but 2 prevents 3 working. Is there a way to ensure the URL has 3 parts or is there a better way to do this?
Thanks