【问题标题】:RewriteRule using $10, $11, $12, and so on使用 $10、$11、$12 等重写规则
【发布时间】:2011-08-16 11:28:34
【问题描述】:

似乎在使用 mod rewrite 时我不能使用正则表达式组,例如

results/(.*?)(/(.*?))(/(.*?))(/(.*?))(/(.*?))(/(.*?))(/(.*?))(/(.*?))(/(.*?))(/(.*?))

这会做这样的事情:

results.php?a=$1&b=$3&c=$5&d=$7&e=$9&f=$11&g=$13&h=$15&i=$17&j=$19

对于其中包含1 的数字,将附加$1 组和一个数字,例如

$1a+typical+get+query

$19 是页码,它会返回a+typical+get+query9,您可以看到页码附加在末尾。

print_r($_GET):

Array
(
    [a] => a typical get query
    [b] => some other field for the query
    [c] => 1
    [d] => 1
    [e] => 1
    [f] => a typical get query1
    [g] => a typical get query3
    [h] => a typical get query5
    [i] => a typical get query7
    [j] => a typical get query9
)

为什么要这样做?

【问题讨论】:

    标签: apache mod-rewrite get


    【解决方案1】:

    在 mod_rewrite 中有 9 个反向引用($1、$2、... $9)的限制。

    $10 $11 等反向引用被解释为只是 $1。

    有关保存反向引用的一些提示,请参阅这篇文章(您必须以不同的方式编写规则): mod_rewrite number of parameters/back-references limitation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-22
      • 1970-01-01
      • 2012-02-25
      相关资源
      最近更新 更多