繁体   English   中英

.htaccess从index.php重定向不起作用

[英].htaccess redirect from index.php not working

我尽力搜索堆栈溢出问题和答案,即使尝试应用解决方案,它也无法正常工作。

我需要重定向所有以

http://www.example.com/index.php?lang=XX

http://www.example.com/XX

这是我尝试的方法:

RewriteCond %{HTTP_HOST} ^www.example\.com [NC]
RewriteRule ^(index\.php\?lang\=)$ http://www.example.com/$1 [L,R=302]

位置/index.php?lang=en 不会重定向/ en(任何位置)。 它在相同的URL。

您无法在重写器中匹配query_string。 您需要一个特定的RewriteCond。 应该或多或少像这样:

RewriteCond %{HTTP_HOST} ^www\.example\.com [NC]
RewriteCond %{QUERY_STRING} ^lang=(.*)
RewriteRule ^ http://www.example.com/%1 [R=302,L,QSD]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM