【问题标题】:Problem with RewriteCond %{QUERY_STRING}, backreference not dispaying in final URLRewriteCond %{QUERY_STRING} 出现问题,反向引用未显示在最终 URL 中
【发布时间】:2011-02-11 19:51:35
【问题描述】:

我的 .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

【问题讨论】:

    标签: mod-rewrite backreference query-string


    【解决方案1】:

    要引用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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-21
      • 2013-04-04
      • 2023-03-15
      • 2010-12-04
      • 2013-07-29
      • 2016-05-03
      • 1970-01-01
      • 2020-08-05
      相关资源
      最近更新 更多