Question about rewrite directive

Francis Daly francis at daoine.org
Thu Jan 28 22:48:13 UTC 2016


On Thu, Jan 28, 2016 at 03:12:16PM +0100, rainer at ultra-secure.de wrote:

Hi there,

> RewriteCond %{REQUEST_FILENAME} !-f
> RewriteCond %{REQUEST_FILENAME} !-d
> RewriteRule ^(.+)\.(\d+)\.(php|js|css|png|jpg|gif|gzip)$ $1.$3 [L]

>     location ~* ^(.+)\.(\d+)\.(js|css|png|jpg|gif|gzip)$ {
>                rewrite ^(.+)\.(\d+)\.(js|css|png|jpg|gif|gzip)$ $1.$3 ;
>                expires 1h;
>     }

> What's wrong with my nginx rewrite?
> Because in apache, the rewrite rule works as intended.

I see two main differences there:

Your apache RewriteRule has [L] on the end. Your nginx rewrite does
not. Possibly you want "break" -- http://nginx.org/r/rewrite

Your apache RewriteRule is protected by RewriteCond. Your nginx rewrite
is not. Possibly something involving try_files or error_page and a named
location for fallback could achieve the same effect.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list