twitcode.org

Login

Home

CodeSnippet from: tolleiv
CodeType: Apache

TinyUrl to this page: http://twitcode.org/Bb

Code:

Label: use browser-lang within mod_rewrite

  1. RewriteCond %{REQUEST_FILENAME} !-f
  2. RewriteCond %{REQUEST_URI} !^/(de|en)/.*$
  3. RewriteCond %{HTTP:Accept-Language} ^de.*$ [NC]
  4. RewriteRule ^(.*)?$ http://www.example.com/de/$1 [L,R=301]
  5.  
  6. RewriteCond %{REQUEST_FILENAME} !-f
  7. RewriteCond %{REQUEST_URI} !^/(de|en)/.*$
  8. RewriteCond %{HTTP:Accept-Language} ^en.*$ [NC]
  9. RewriteRule ^(.*)?$ http://www.example.com/en/$1 [L,R=301]

Comment:

Small snippet how to make use of the HTTP:Accept-Language with mod_rewrite

Tag Cloud

Sorry, looks like you have no flash or js.