Reputation:
I'm totally clueless when it comes to mod_rewrite, so I'll be glad to get any help. I just want Apache to redirect my homepage according to the detected country language. My PHP is auto-translating in multiple languages and I'm trying to avoid multiplying the same exact Site to subdomains and domains because of SEO - but looks like Google is not so advanced yet, giving no other choice.
e.g.
mysite.com to:
mysite.com/index.php?lang=nl for holland
mysite.com/index.php?lang=fr for france
and for no specified country code just to:
mysite.com/index.php?lang=be
mysite.com/?lang=nl wwould also be fine
I'll also be happy to hear a better suggestion. I tried the following with no succes
RewriteCond %{HTTP:Accept-Language} ^nl[NC]
RewriteRule ^index\.html /index\.php?lang=nl [QSA,NC,L]
RewriteCond %{HTTP:Accept-Language} ^fr[NC]
RewriteRule ^index\.html /index\.php?lang=fr [QSA,NC,L]
I'm just getting a server error - Couldn't find an exact case that could help
Upvotes: 1
Views: 159
Reputation: 18671
Try with:
RewriteCond %{HTTP:Accept-Language} ^(nl|fr) [NC]
RewriteRule ^(index\.html)?$ /index.php?lang=%1 [QSA,NC,L]
RewriteRule ^(index\.html)?$ /index.php?lang=be [QSA,NC,L]
Upvotes: 1