简体   繁体   中英

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.

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 :

RewriteRule backreferences:
These are backreferences of the form $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. $0 provides access to the whole string matched by that pattern.

You need to refactor your rule to use backreference upto $9 Your rule can be possibly rewritten as:

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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