htaccess redirect subfolder of certain domain

419 views Asked by At

I have a multi-subdomain multi-lingual website setup and I need to redirect a language subfolder of a certain domain. eg. au.domain.com/us/request_uri to au.domain.com/en/request_uri. This rule needs to be ignored on other domains. All domains are run off the same codebase and all use the one htaccess file (drupal install with domain access module). This shouldn't affect how the htaccess rule is set though.

1

There are 1 answers

1
Felipe Alameda A On

Here is one way to do it:

RewriteEngine On
RewriteRule ^us/(.*)$ http://au.domain.com/en/$1 [L,R=301]

Redirects:

http://au.domain.com/us/anything to

http://au.domain.com/en/anything/

UPDATED

RewriteEngine On
RewriteRule http://au.domain.com/us/^(.*)$ http://au.domain.com/en/$1 [L,R=301]

Only http://au.domain.com/us/anything will be redirected to

http://au.domain.com/en/anything/

OR

RewriteEngine On
RewriteCond %{HTTP_HOST} ^au.domain\.com$ [NC]
RewriteRule ^us/(.*)$ http://au.domain.com/en/$1 [L,R=301]

Hope this helps.