Accept-Language based redirection

I need to read a list of web browser language preferences. Supported languages: English and French. For example: http_accept_language = "jp-JP; fr; en-US; en" is redirected to a directory named / French /. How can I do this using rewrite rules in my .htaccess file?

+3
source share
1 answer

I would not use mod_rewrite for this, but a more powerful language. Since Accept-Language is a list of weighted values ​​(see quality value ), and the appearance of one of the identifiers does not mean that it is preferable to another value (especially q=0means unacceptable in general).

As already mentioned, use a more powerful language than mod_rewrite, analyze the list of values ​​and find the best match between the preferred parameters and the available parameters.

+3
source

Source: https://habr.com/ru/post/1746670/


All Articles