Redirect based on Accept-Language

瘦欲@ 提交于 2019-12-10 19:49:25

问题


I need to honor the web browser's list of language preferences. Supported languages are English and French. For example: http_accept_language="jp-JP;fr;en-US;en" redirects to a directory called /French/. How can I do this with rewrite rules in my .htaccess file?


回答1:


I wouldn’t use mod_rewrite for this but a more powerful language. Because Accept-Language is a list of weighted values (see quality value) and the occurrence of one of the identifiers does not mean that it’s preferred over another value (especially q=0 means not acceptable at all).

As already said, use a more powerful language than mod_rewrite, parse the list of value and find the best match of preferred options and available options.



来源:https://stackoverflow.com/questions/2888038/redirect-based-on-accept-language

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!