在htaccess中重定向俄罗斯URL不起作用

时间:2013-05-16 08:56:08

标签: .htaccess redirect

我在Wordpress网站上更改了我的网址结构。所以我使用.htaccess文件来重定向URL。当我在.htaccess中添加以下代码时,网址www.mydomain.com/test/?lang=en会正确地重定向到www.test.com

RewriteEngine On
RewriteCond %{QUERY_STRING}  ^lang=en$ [NC]
RewriteRule ^test/$ http://www.test.com/? [R=301,NE,NC,L]

我的网站也是俄语。 我的目标是将www.mydomain.com/шарон/?lang=RU重定向到www.test.com

我尝试将以下代码添加到.htaccess:

RewriteCond %{QUERY_STRING}  ^lang=RU$ [NC]
RewriteRule ^%D1%88%D0%B0%D1%80%D0%BE%D0%BD/$ /www.test.com? [R=301,NE,NC,L]

但重定向不起作用。我得到了“无法显示页面”错误,我认为是404错误。

我还尝试将俄文文本添加到.htaccess文件中。并将.htaccess保存为UTF-8文件格式。

RewriteCond %{QUERY_STRING}  ^lang=RU$ [NC]
RewriteRule ^шарон/$ /www.test.com? [R=301,NE,NC,L]

然后我收到以下信息,我的网站不再可用。

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.

服务器错误日志中可能提供了有关此错误的更多信息。

有没有人知道如何重定向我的俄语网址?

1 个答案:

答案 0 :(得分:3)

我不确定在重写时是否可以这样指定URL。尝试将其更改为

RewriteCond %{QUERY_STRING}  ^lang=RU$ [NC]
RewriteRule ^\xd1\x88\xd0\xb0\xd1\x80\xd0\xbe\xd0\xbd/$ /www.test.com? [R=301,NE,NC,L]

其中

  

\ XD1 \ X88 \ XD0 \ XB0 \ XD1 \ X80 \ XD0 \ XBE \ XD0 \ XBD

等于

  

%D1%88%D0%B0%D1%80%D0%BE%D0%BD

因此也

  

шарон

希望它有所帮助。如果您有其他问题,请对此进行评论。 ;)