nginx rewrite bug

Igor Sysoev igor at sysoev.ru
Thu May 20 19:50:49 MSD 2010


On Thu, May 20, 2010 at 11:02:14PM +0800, val lee wrote:

> nginx version:0.8.37
> I write:
> rewrite ^/page([0-9]+)-t([a-zA-Z]+)-g([0-9]+)-t([0-9]+)-a([0-9]+)-s([0-9]+)-p([0-9]+)-t([0-9]+)-o(.+)-w(.*)\.html$
> /search/search.do?pg=$1&tp=$2&gm=$3&ts=$4&aa=$5&sr=$6&pz=$7&type=$8&ord=$9&wd=$10
> last;
> 
> $10 is rewrited $1 and 0.Don't nginx supports $10 or $11....?
> But i see http://aleksandarsavic.com/
> 
> Nginx rewrite rules for XtraUpload:
> if (!-e $request_filename) {
> # New Rewrite Rules for total site SEO
> rewrite ^/(.*)/(.*)_(.*)/(.*)_(.*)/(.*)_(.*)/(.*)_(.*)/(.*)_(.*)/index\.htm$
> /$1.php?$2=$3&$4=$5&$6=$7&$8=$9&$10=$11 last;
> .......

Yes, nginx does not support $10 and $11, but you may use named captures:

     ... -o(.+)-w(?<n0>.*)\.html$

     ... &ord=$9&wd=$n0


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list