根据接受语言重定向重定向、根据、语言

2023-09-02 09:45:49 作者:不和群的小仙女

我要兑现的语言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.