htaccess RewriteRule用于按语言进行子域重定向

时间:2015-11-05 00:14:26

标签: php apache .htaccess mod-rewrite

我有一个英文网站http://example.com

如果浏览器语言为PT,我想添加重定向到我的子域PT语言http://pt.example.com的代码

RewriteEngine on
RewriteCond %{HTTP:Accept-Language} (pt) [NC]
RewriteRule .* http://pt.example.com [R,L]

当我添加它时,我在浏览器中得到一个重定向循环。

我已尝试example.com/pt并从浏览器中收到相同的错误。

1 个答案:

答案 0 :(得分:0)

添加RewriteCond:

RewriteCond %{HTTP_HOST} !^pt\.example\.com