根据接受语言重定向 [英] Redirect based on Accept-Language

查看:134
本文介绍了根据接受语言重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要兑现的语言preferences Web浏览器的列表。支持的语言是英语和法语。例如:HTTP_ACCEPT_LANGUAGE =JP-JP; FR; EN-US;恩重定向到一个名为/法语/目录。我怎样才能做到这一点与重写规则在我的.htaccess文件?

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?

推荐答案

我不会使用mod_rewrite可以实现,但更强大的语言。因为接受语言的是加权值的列表(见质量值)和标识符之一的发生并不意味着它是pferred在另一个价值$ P $(尤其是 Q = 0 表示不接受的话)。

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).

前面已经说了,使用更强大的语言比mod_rewrite的,分析的价值列表,找到了preferred选项和可选项的最佳匹配。

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.

这篇关于根据接受语言重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆