Need rewrite help

Hi,

please help me to rewrite this mod_rewrite rule:

RewriteRule (img/(.+))$ webroot/$1 [L]

Thanks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215460,215460#msg-215460

On 20 Set 2011 22h38 WEST, [email protected] 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.

— appa

21.09.2011, 04:50, “António P. P. Almeida” [email protected]:

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.

On Wed, Sep 21, 2011 at 04:57:10AM +0700, Denis F. Latypoff wrote:

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

I think $1 in RewriteRule is a whole “img/…”:

$ pcretest
PCRE version 7.9 2009-04-11

re> #(img/(.+))$#
data> img/qqq
0: img/qqq
1: img/qqq
2: qqq
data> ^D

So it should be “root”:

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


Igor S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs