Language redirect using .htaccess

I have two versions of the same page:

  • example.com
  • example.com/fr -> French version

I would like French people who access to mydomain.com to be redirected to mydomain.com/fr based on the header Accept-language. To do that I wrote this into my .htaccess:

RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule ^$ http://example.com/fr/ [L,R=301]

I works perfect so far.

But in my site there are links to the French / English versions… When a French user who is in the French version clicks on the english link, he comes back to the french version… How can I avoid this? How can I distinguish he actually wants to go to the English version?


Source: .htaccess

Leave a Reply