我如何使用.htaccess将不同的语言重定向到不同的页面?

时间:2011-04-11 19:49:28

标签: html .htaccess mod-rewrite redirect

我正在尝试制作一个简单的双语网站,我和陌生人不熟悉.htaccess但找到了一个在线工具:http://www.htaccesstools.com/redirection-by-language/

我希望英文浏览器转到我的根文件夹的index.html,将泰语浏览器转到子文件夹。

我从发电机得到的是:

RewriteEngine on
RewriteCond %{HTTP:Accept-Language} th [NC]
RewriteRule .* http://www.mysite.com/th/index.html [R,L]

这不起作用,我得到一个重定向循环/其他错误。我已经尝试将最后一行的url更改为相对,但这不会影响它。

任何帮助?

*确认,我只在我的根文件夹中有一个.htaccess

1 个答案:

答案 0 :(得分:1)

在.htaccess文件中尝试此操作:

Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_URI} !^(/th/index.html|.*\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt))$ [NC]
RewriteCond %{HTTP:Accept-Language} ^th [NC]
RewriteRule .* /th/index.html [R,L,QSA,NE]