我正在尝试让mod_rewrite正常工作。
以下是代码:
RewriteCond %{QUERY_STRING} ^main_page=product_info&products_id=301$
RewriteRule ^index\.php$
/blog/shop/index.php?route=product/product&product_id=301? [R=301,L]
它可以工作,但是在新URL的末尾添加了%3f。 有人可以帮助我让它发挥作用吗?
答案 0 :(得分:0)
在最后放置无逃生标志NE:
RewriteRule ^index\.php$
/blog/shop/index.php?route=product/product&product_id=301? [R=301,L,NE]
答案 1 :(得分:0)
%3f是您声明末尾的问号。拿出来,你应该是好的。
RewriteCond %{QUERY_STRING} ^main_page=product_info&products_id=301$
RewriteRule ^index\.php$
/blog/shop/index.php?route=product/product&product_id=301 [R=301,L]
答案 2 :(得分:0)
%3f是“?”你有“目标网址”的末尾 - 只有网址转义。这真的应该在那里吗?
答案 3 :(得分:0)
%3f
是替换结束时的?
百分比编码。只需将?
放在最后:
RewriteCond %{QUERY_STRING} ^main_page=product_info&products_id=301$
RewriteRule ^index\.php$ /blog/shop/index.php?route=product/product&product_id=301 [R=301,L]
您最后只能使用?
来表示空查询,以便在未包含查询的情况下,请求的查询不会附加到新网址。