I need to redirect the following URL which has the country code at the start:
http://xx.domain.com/test.html
into:
http://xx.domain.com/xx_en/test.html
I came up with the following, of course this will have an infinite loop:
RewriteCond %{REQUEST_URI} !/xx_en/ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com [NC]
RewriteRule (.*) /%1_en/$1 [R=301,L]
So I added the first line which, I think, means if you don’t see /xx_en/ in the request_uri then do what follows.
Any idea what I’m doing wrong?
Use something like the following set of rules:
You can understand it like: for all requests to all 3rd level domains under domain.com which doesn’t start with /<3rd level>_en/ redirect to it…