我需要将一个动态URL重定向到另一个,但参数略有更改。这是原始URL:
http://www.EXAMPLE.com/index.php?main_page=index&cPath=5
并且需要重定向到
http://www.EXAMPLE.com/index.php?main_page=index&cPath=25
我尝试了很多不同的变体,但似乎没有一个有效。
RewriteCond %{QUERY_STRING} ^main_page=index&cPath=5$
RewriteRule ^/(index'.php|)$ http://www.EXAMPLE.com/index.php?main_page=index&cPath=25 [L,R=301]
我快疯了。。。有人能告诉我正确的方向,告诉我做错了什么吗?
我认为前导斜杠是您的模式中的问题。在你的根目录中试试这个规则。htaccess:
RewriteCond %{QUERY_STRING} ^main_page=index&cPath=5$ [NC]
RewriteRule ^/?(index'.php)?$ /$1?main_page=index&cPath=25 [NC,L,R=301]
也许没有条件?
RewriteEngine on
rewriterule ^index.php?main_page=index&cPath=5$ http://www.EXAMPLE.com/index.php?main_page=index&cPath=25 [r=301,nc]