[英]Rewrite rule based on QUERY_STRING
I am trying to redirect the url 我正在尝试重定向网址
www.mydomain.com/index.php?route=first/second to www.mydomain.com/second I have tried the following rules but none seem to work www.mydomain.com/index.php?route=first/second至www.mydomain.com/second我尝试了以下规则,但似乎没有用
RewriteEngine On
1) RewriteRule ^index.php?route=first/second$ /second [R=301,L]
2) RewriteRule ^index.php?route=first/second$ www.mydomain.com/second [R=301,L]
3) Redirect ^index.php?route=first/second /second/
4) Redirect ^index.php?route=first/second www.mydomain.com/second/
5) Redirect ^www.mydomain.com/index.php?route=first/second /second/
6) Redirect ^www.mydomain.com/index.php?route=first/second www.mydomain.com/second/
However the below rule works: RewriteRule ^second$ /index.php?route=first/second [R=301,L]
but point 1 and 2 above does not work 但是,以下规则有效:
RewriteRule ^second$ /index.php?route=first/second [R=301,L]
但上面的第1点和第2点不起作用
Is there any solution to this? 有什么解决办法吗?
确保在任何规则之前都将RewriteEngine On
。
Make sure: index.php
exists, else for that we have to set some condition for file existence
as well like RewriteCond %{REQUEST_FILENAME} !-f
确保:
index.php
存在,否则,我们必须为file existence
设置一些条件,例如RewriteCond %{REQUEST_FILENAME} !-f
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} route=first/second
RewriteRule .* /second? [R,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.