0
我正在尝试将博客的访问者重定向到法语或英语版本。 所以我做了这个的.htaccess:.htaccess:语言重定向
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
#---------------------
# Language Redirection
#---------------------
# Checking if the redirection didn't occur yet
# Checking that the url doesn't begin with /en
RewriteCond %{REQUEST_URI} !^/en(.*)$
# Checking if the user is in english
RewriteCond %{HTTP:Accept-Language} ^en [NC]
# Redirecting from /the/url to /en/the/url
RewriteRule ^(.*)$ /en/$1 [L,R=301]
#----------------------
# Wordpress Redirection
#----------------------
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
基本上,我想我的访问者来自谷歌未来的/我/条重定向到/ EN /我/文章,如果他们是英语。 相反,有一个无限循环!我认为REQUEST_URI始终是index.php,因为最后一个RewriteRule。
有没有人做过这个?
非常感谢
感谢您的回答。 基本上,如果用户在其语言列表的开始处放置英语,那么我的.htaccess中的RewriteCond将会被释放,因此他将被重定向。 – 2010-08-06 16:15:53
@Benjamin Netter:但在开始时使用'en'并不意味着英语是最受欢迎的语言。它可能具有1以外的质量值(可能甚至为0),并且可能有其他语言优于英语。那么,为什么你不用PHP来进行语言协商,你可以做的不仅仅是简单的字符串比较? – Gumbo 2010-08-06 16:26:35
这不是我想要做的。 – 2010-08-06 16:47:26