【发布时间】:2011-11-22 22:49:26
【问题描述】:
我正在尝试将文章从我的博客重定向到他们的英文版。
基本上,一篇文章 /my/article 是法语的。但是您可以在 /en/my/article 访问英文版。如果用户不是法国人,我需要重定向到这个网址。
我在我的 .htaccess 中制定了这条规则:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:Accept-Language} !^fr [NC]
RewriteCond %{REQUEST_URI} !^/en [NC]
RewriteRule ^(.*)$ /en/$1 [L,R]
</IfModule>
当我要去 /my/articles 时,我实际上被重定向到 /en/index.php。 我认为这是因为 Wordpress 默认重定向:
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
我怎样才能做到这一点?
【问题讨论】:
-
这些规则的顺序是什么?
-
另外,尝试将 [L,R] 更改为 [R]
-
我把这条规则放在我的 .htaccess 的开头
-
我从 [L,R] 更改为 [R] 并且我明白了:发现文档已移至此处。此外,在尝试使用 ErrorDocument 处理请求时遇到 500 Internal Server Error 错误。
-
那么,你的规则在开头,wordpress 的规则在结尾?它们在同一个文件中吗?
标签: apache wordpress .htaccess