Simple Rewrite Question
Chris Sturgill
chris at rizyn.com
Sat Feb 7 02:45:13 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;
> }
>
>
Thank you much! I had tried putting $1 directly into the rewrite
without setting a separate variable, but got yelled at for not having a
matching term in the left-hand side of the rewrite equation. This
simple answer just solved several days of frustration!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20090206/46e2bf3a/attachment.html>
More information about the nginx
mailing list