Redirect on $args based on multiple params?
Igor Sysoev
is at rambler-co.ru
Wed Mar 25 18:59:46 MSK 2009
On Wed, Mar 25, 2009 at 03:55:02PM +0000, Phillip B Oldham wrote:
> Is there any way to capture multiple parameters from a querystring for a
> rewrite?
>
> For example:
> The request is: /myscript.php?a=b&c=d&z=y
> The target is: /script/a/b/c/d/z/y
>
> So, the basic rewrite would be:
>
> location /myscript.php {
> if( $args ~* ^a=([^\&]+)&b=([^\&]+)&z=([^\&]+)$ ){
> rewrite ^ /script/a/$1/b/$2/z/$3 permanent;
> }
> }
>
> However, how would I cope with situations where the args aren't in the
> order of a/b/z? Obviously if I have 10 args I don't want to have to do
> an "if" for each permutation, that could get both confusing and lengthy!
No way. This is one of the reasons why locations test URI only.
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list