Simple Rewrite Question

Igor Sysoev is at rambler-co.ru
Fri Feb 6 22:59:45 MSK 2009


On Fri, Feb 06, 2009 at 02:53:25PM -0500, Chris Sturgill wrote:

> I promise I've paid due diligence trying to solve this one through 
> Google, but just can't come up with the solution (I've probably 
> overlooked something very simple).
> 
> In Apache, I can forward a captured variable from a RewriteCond check 
> like this:
> RewriteCond %{QUERY_STRING} tag=(.*)
> RewriteRule ^fastsearch(.*) /tags/%1? [L,R=301]
> 
> but I can't seem to find the nginx equivalent as the following doesn't work:
> if ($query_string ~ "tag=(.*)") {
>    rewrite ^/fastsearch.* /tags/%1? permanent;
> }
> 
> My server admin is requiring that we run the stable version (0.6.35) so 
> I can't use the $arg_PARAMETER introduced in 0.7.*.
> 
> What am I missing?

 if ($query_string ~ "tag=(.*)") {
    set  $tag  $1;
    rewrite ^/fastsearch.* /tags/$tag? permanent;
 }
 

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





More information about the nginx mailing list