I have three different domains pointing to the same WordPress's host instance depending on the language (managed with the qTranslate plugin):
RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.cat$
RewriteRule ^/?$ "http\:\/\/ca\.mydomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$
RewriteRule ^/?$ "http\:\/\/en\.mydomain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.es$
RewriteRule ^/?$ "http\:\/\/es\.mydomain\.com\/" [R=301,L]
With that I've managed to achieve the following redirects:
- mydomain.cat or www.mydomain.cat ---> ca.mydomain.com ---> Shows website in catalan
- mydomain.es or www.mydomain.es ---> es.mydomain.com ---> Shows website in spanish
- mydomain.com or www.mydomain.com ---> en.mydomain.com ---> Shows website in english
Now the trouble I have is that, for example, user types mydomain.cat/work it doesn't works fine, it goes to mydomain.com/work/ and the language part in the subdomain is missing. It would be perfect if, in that case, it redirects to ca.mydomain.com/work.
I've researched and tried to modify the three RewriteCond rules to "add" the additional content at the end of the url (don't know if is better with QUERY_STRING or with parameters) if it exists, but I couldn't get it working fine, rather I don't know if it's the best way to achieve it.
Anyone can help me or give me a clue?