2

My qTranslate-X (v3.4.6.4) WordPress (v4.4.2) plugin can't "Detect the language of the browser and redirect accordingly.", so i needed to do a hack by .htaccess. Following solution found in Drupal's .htaccess (Because none of the stackexchange's answer was working well)

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP:Accept-Language} de [NC]
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteCond %{QUERY_STRING} !(^index.php) [NC]
RewriteRule ^(.*)$ /de [L,R=302]

RewriteCond %{HTTP:Accept-Language} hu [NC]
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteCond %{QUERY_STRING} !(^index.php) [NC]
RewriteRule ^(.*)$ /hu [L,R=302]

RewriteCond %{HTTP:Accept-Language} ro [NC]
RewriteCond %{REQUEST_URI} ^/$ [NC]
RewriteCond %{QUERY_STRING} !(^index.php) [NC]
RewriteRule ^(.*)$ /ro [L,R=302]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.php [L]

Tested under Window 7 and Windows 10, both has the following regional settings:

  • Location/Country: Romania
  • System Language: English
  • Date and Currency format: Hungarian
  • Default keyboard language: hu

English Google Chrome with User Agent:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36

redirect to /hu

English Internet Explorer with User Agent:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; MRA 8.2 (build 6901);

redirect to /hu

Any language Mozilla Firefox with User Agent:

Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0

redirect to nothing

All cache and History are cleared.

There is any real solution for this!?

  • It seems that you're saying that all English browsers except Firefox, in any language, is being redirected to /hu, which is what you want, and you're looking for htaccess code that would result in Firefox also being redirected the same way as the other browsers? If so, can you edit the question to clarify that? – dan Mar 18 '16 at 5:21
  • What request headers are being sent by the browsers? Specifically, what is contained in the Accept-Language header? (Aside: What is this check for... %{QUERY_STRING} !(^index.php)?) – MrWhite Mar 18 '16 at 11:54