Mobile app version of vmapp.org
Login or Join
XinRu657

: Strange HTTP:Accept-Language behavior instead of Browser Language Detect My qTranslate-X (v3.4.6.4) WordPress (v4.4.2) plugin can't "Detect the language of the browser and redirect accordingly.", so

@XinRu657

Posted in: #Apache #Htaccess #ModRewrite #Wordpress

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!?

10% popularity Vote Up Vote Down


Login to follow query

More posts by @XinRu657

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme