Is it possible to rewrite url using query args? I mean rewriting sth
like
/get_file?file=bleh.zip
to
/download/bleh.zip
?
I tried the naive solution, but it seems rewrite regexps does not have
access to query args at all…
–
Is it possible to rewrite url using query args? I mean rewriting sth
like
/get_file?file=bleh.zip
to
/download/bleh.zip
?
I tried the naive solution, but it seems rewrite regexps does not have
access to query args at all…
–
Marcin K. [email protected] 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;
}
On Tue, Nov 06, 2007 at 06:44:55PM +0100, Marcin K. wrote:
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 ...
}
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs