RewriteCond %{QUERY_STRING} 出现问题,反向引用未在最终网址中显示

发布于 2024-08-30 14:45:43 字数 501 浏览 2 评论 0 原文

我的 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

人疚 2024-09-06 14:45:43

要引用 RewriteCond 指令的子匹配,您需要使用 %n 而不是 $n

RewriteCond %{QUERY_STRING} ^route=product/category&path=35&page=([0-9]+)$
RewriteRule ^index\.php$ /product/category/35/page_%1? [R=301,L]

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]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文