How to rewrite a url based on accept-language

Posted by Anthony Faull on Stack Overflow See other posts from Stack Overflow or by Anthony Faull
Published on 2010-05-22T12:18:29Z Indexed on 2010/05/22 12:20 UTC
Read the original article Hit count: 354

Filed under:
|

I have a website in three languages with a directory for each: i.e. /en-US/, /de-DE/ and /fr-FR/. I would like the web server to use the browser's accept-language string to return content in the language of the user.

Examples: (a) "pl-PL;fr-FR;en-US" should redirect to /fr-FR/. (b) "de;fr-FR" redirects to /de-DE/ (c) "jp-JP" redirects to /en-US/.

How would I do this in an .htaccess file?

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about url-rewriting