RewriteCond %{QUERY_STRING} 出现问题,反向引用未在最终网址中显示
我的 .htaccess 文件中有以下内容:
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 时,它的行为并不符合预期:
http://example.com/index.php?route=product/category&path=35&page=2
它被重写为:
http://example.com/product/category/35/page_
有人可以告诉我我做错了什么吗?
谢谢,
eb_dev
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]
It's not behaving as expected though, when I enter the URL:
http://example.com/index.php?route=product/category&path=35&page=2
It gets rewritten to:
http://example.com/product/category/35/page_
Could someone tell me what I have done wrong please?
Thanks,
eb_dev
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要引用
RewriteCond
指令的子匹配,您需要使用%n
而不是$n
:To reference submatches of a
RewriteCond
directive, you need to use%n
instead of$n
: