Rewriting using query args?
Igor Sysoev
is at rambler-co.ru
Wed Nov 7 14:21:01 MSK 2007
On Tue, Nov 06, 2007 at 06:44:55PM +0100, Marcin Kasperski wrote:
> Marcin Kasperski <Marcin.Kasperski at softax.com.pl> writes:
>
> > Is it possible to rewrite url using query args? I mean rewriting sth
> > like
> > /get_file?file=bleh.zip
> > to
> > /download/bleh.zip
>
> I asked stupid question so I will answer it myself.
>
> Sth like
>
> if ( $args ~ file=(.*)\.zip ) {
> set $file $1;
> rewrite ^/get_file /download/$1 redirect;
> break;
> }
Yes. An extrbal redirect
location = /get_file {
if ( $args ~ file=(.*)\.zip ) {
set $file $1;
rewrite ^ /download/$1 redirect;
}
return 404;
}
or internal redirect:
location = /get_file {
if ( $args ~ file=(.*\.zip) ) {
set $file $1;
rewrite ^ /download/$1 last;
}
return 404;
}
location /download {
root ...
}
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list