RewriteCond%{QUERY_STRING}出现问题,反向引用未在最终到达的网址中支付 [英] Problem with RewriteCond %{QUERY_STRING}, backreference not dispaying in final URL
本文介绍了RewriteCond%{QUERY_STRING}出现问题,反向引用未在最终到达的网址中支付的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
.htaccess文件中包含以下内容:
I have the following in my .htaccess file:
RewriteCond %{QUERY_STRING} ^route\=product\/category\&path\=35\&page\=([0-9]+)$
RewriteRule ^index\.php$ http://%{HTTP_HOST}/product/category/35/page_$1? [R=301,L]
当我输入URL时,它的表现却不符合预期:
It's not behaving as expected though, when I enter the URL:
http://example.com/index.php?route=product/category&path=35&page=2
它被重写为:
http://example.com/product/category/35/page_
有人可以告诉我我做错了什么吗?
Could someone tell me what I have done wrong please?
谢谢
eb_dev
推荐答案
要引用RewriteCond
指令的子匹配项,您需要使用%n
而不是$n
:
To reference submatches of a RewriteCond
directive, you need to use %n
instead of $n
:
RewriteCond %{QUERY_STRING} ^route=product/category&path=35&page=([0-9]+)$
RewriteRule ^index\.php$ /product/category/35/page_%1? [R=301,L]
这篇关于RewriteCond%{QUERY_STRING}出现问题,反向引用未在最终到达的网址中支付的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文