3 messages in ru.sysoev.nginxRe: Apache rewrite in Nginx format
FromSent OnAttachments
Philip MurraySep 25, 2007 9:18 pm 
Igor SysoevSep 26, 2007 4:13 am 
Philip MurraySep 26, 2007 7:04 pm 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Apache rewrite in Nginx formatActions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Sep 26, 2007 4:13:55 am
List:ru.sysoev.nginx

On Wed, Sep 26, 2007 at 04:18:43PM +1200, Philip Murray wrote:

Is it possible to express the following Apache rewrite rule in Nginx?

RewriteCond %{QUERY_STRING} !^nobranding$ RewriteCond %{REQUEST_FILENAME} ^/assets/XL/([^.]+)\.([jpegif]+)$ RewriteCond /usr/local/www/assets-nz/XL/%1.branded.%2 -f RewriteRule ^/([^.]+)\.([jpeg]+)$ /$1.branded.$2

In Nginx, this would be in a location block with an alias, so

location /assets { alias /usr/local/www/assets-nz/;

... rewrites go here ... }

But, I understand you can't rewrite with an alias present? So how can I implement the above Apache rewrite?

Try

location /assets {

if ($args = nobranding) { rewrite ^(.+)$ /nobranding$1 last; }

rewrite ^/assets/XL/(.+)\.(jpeg|jpg|gif) /XL/$1.branded.$2; root /usr/local/www/assets-nz; error_page 404 = /nobranding/assets$uri; }

location /nobranding/assets { internal; alias /usr/local/www/assets-nz/; }