need rewrite help

Denis F. Latypoff latypoff at yandex.ru
Tue Sep 20 21:57:10 UTC 2011


21.09.2011, 04:50, "António P. P. Almeida" <appa at perusio.net>:
> On 20 Set 2011 22h38 WEST, nginx-forum at nginx.us wrote:
>
>>  Hi,
>>
>>  please help me to rewrite this mod_rewrite rule:
>>  RewriteRule    (img/(.+))$ webroot/$1     [L]
>
> Try:
>
> location ^~ /img/ {
>     location ~* /img/(.+)$ {
>        return 301 /webroot/$1;
>    }
> }
>
> Or 302 if you want it to be temporary.

There is no [R] flag in the rewrite rule, so it should be internal redirect

location /img/ {
    alias /path/to/webroot/;
}

-- 
br, Denis F. Latypoff.



More information about the nginx mailing list