I have a rewrite rule that works ok but does not do it silently.
Including
http://... in the RewriteRule substitution causes the redirect.
Try
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$ [NC]
RewriteCond %1 !=www [NC]
RewriteRule ^([a-z]+)(/(.*))?$ http://www.mysite.com/$3?lang=$1 [L]
I presume the sub domain requests go to your main document root.
If the sub domain is the language code, you could have en.example.com/file instead of en.example.com
/en/file with
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([a-z]+)\.example\.com$ [NC]
RewriteCond %1 !=www [NC]
RewriteRule ^(.*)$ http://www.mysite.com/$1?lang=%1 [L]
Not with mod_rewrite (which tells the user's browser to go to a different URL, which will always be displayed). Maybe Virtual Hosts can help you? That's what I would use.
FAQ:
Virtual sub domains.