简体   繁体   English

重写htaccess中的规则问题

[英]rewrite rule issue in htaccess

I have the following rule which is working 我有以下规则正在起作用

RewriteRule ^(.+?)/(step)/([0-9]+)/(id)/([0-9]+)/(start)/([0-9]+)/(end)/
([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5&$6=$7&$8=$9 [NC,L,QSA]

Now I wanted to add another param at the end of the string which is (ansid) so I did in the following way but for some reason it is not picking up the ansid. 现在,我想在字符串的末尾添加另一个参数(ansid),因此我按以下方式进行操作,但是由于某种原因,它没有选择ansid。

RewriteRule ^(.+?)/(step)/([0-9]+)/(id)/([0-9]+)/(start)/([0-9]+)/(end)
/([0-9]+)/(ansid)/([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5&$6=$7&$8=$9&$10=$11 
[NC,L,QSA]

$10 and $11 won't work because as per Apache mod_rewrite manual : $10$11无法使用,因为按照Apache mod_rewrite手册

RewriteRule backreferences: RewriteRule反向引用:
These are backreferences of the form $N (0 <= N <= 9). 这些是形式为$ N(0 <= N <= 9)的反向引用。 $1 to $9 provide access to the grouped parts (in parentheses) of the pattern, from the RewriteRule which is subject to the current set of RewriteCond conditions. $ 1到$ 9可从RewriteRule访问模式的分组部分(在括号中),该条件取决于当前的RewriteCond条件集。 $0 provides access to the whole string matched by that pattern. $ 0提供对该模式匹配的整个字符串的访问。

You need to refactor your rule to use backreference upto $9 Your rule can be possibly rewritten as: 您需要重构规则以使用$9反向引用。您的规则可能被重写为:

RewriteRule ^(.+?)/(step)/([0-9]+)/(id)/([0-9]+)/(start)/([0-9]+)/end/([0-9]+)/ansid/([0-9]+)/?$ index.php?url=$1&$2=$3&$4=$5&$6=$7&end=$8&$ansid=$9 [NC,L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM