I’m hoping to get some help with an htaccess solution for the following redirects:
Case 1) the user enters domain.com it should redirect to domain.com/nl
Case 2) if the user enters domain.com/nl or domain.com/fr it should not redirect
Case 3) the user enters domain.com/some-path it should capture the url path and stick /nl in front of it, domain.com/nl/some-path
So far I’ve tried the following rule:
Redirect 301 ^((?!(?:)nl($)|(?:)fr($)).)*$ domain.com/nl/$1
However in Case 3, only the final character of the path is selected and not the whole ‘some-path’.
Using multiple rules is ok too, but can it be done in a single rule?
2
Answers
It can be done in single rule like this:
Could you please try following, written and tested with shown samples. Please make sure you clear your browser cache before testing your URLs.