a regex for rewrite

etrader nginx-forum at nginx.us
Wed Sep 4 22:54:06 UTC 2013


I have a set of rewrites as

rewrite ^/(.*)/(.*)/(.*)\.(.*) /script.php?a=$1&b=$2&c=$3&ext=$4 last;
rewrite ^/(.*)/(.*)\.(.*) /script.php?a=$1&b=$2&ext=$3 last;
rewrite ^/(.*)\.(.*) /script.php?a=$1&ext=$2 last;
rewrite ^/(.*)/(.*)/(.*)/(.*) /script.php?a=$1&b=$2&c=$3&d=$4 last;
rewrite ^/(.*)/(.*)/(.*) /script.php?a=$1&b=$2&c=$3 last;
rewrite ^/(.*)/(.*) /script.php?a=$1&b=$2 last;

How can I use one single rewrite rule to match all possible choices?

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,242547,242547#msg-242547



More information about the nginx mailing list