【发布时间】:2018-08-01 18:16:27
【问题描述】:
我有一个重写规则,在访问没有参数的直接 URL 时有效。
示例网址:http://mev-hongkong.com/product-category/babies-tots/
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mev-hongkong\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^product-category/babies-tots(/.*)?$ https://mothersenvogue.com.hk/shop/all-babies-tots$1 [L,R=301,NC,NE]
但是,我也有相同的 URL,它们有一个参数,我还需要重定向到相同的 URL 输出。我尝试操纵重写规则并添加了一个%{QUERY_STRING} 条件,如下面的规则,但是当我使用具有参数的 URL 对其进行测试时,查询字符串仍然没有被删除。
带参数的示例网址:http://mev-hongkong.com/product-category/babies-tots/?add_to_wishlist=8836
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mev-hongkong\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{QUERY_STRING} ^add_to_wishlist=([^&]+) [NC]
RewriteRule ^product-category/babies-tots(/.*)?$ https://mothersenvogue.com.hk/shop/all-babies-tots$1 [L,R=301,NC,NE]
为了正确剥离查询字符串,我错过了什么?
【问题讨论】:
标签: .htaccess mod-rewrite