nginx rewrite does not work without "permanent" directive

Francis Daly francis at
Fri Dec 15 13:18:00 UTC 2017

On Fri, Dec 15, 2017 at 03:48:20PM +0300, Alexander Trofimchouk wrote:

Hi there,

> My nginx rewrite works only if I add "permanent" directive. Without it there
> is no rewrite seen even in browser's network log.

"rewrite" does not directly lead to "http redirect" without specific

> For example: User requests,
> Nginx tries to find the file or redirects to

No, that's not what your config says.

nginx *rewrites* to /www2/web/app_dev.php/images/cache?path=thumb/1.jpg

That rewritten request (depending on the omitted config) probably is
handled within

  location ~ ^/www2/web/(app_dev|config)\.php(/|$) {

which does the fastcgi_pass to PHP.

If you want nginx to *redirect*, you have to tell it to, using one of
the three documented methods.

> If I add "permanent" I get Symfony controller output in browser - which is
> OK. What did I do wrong?

You left off "permanent" or "redirect" or didn't start the replacement
string with "http://", if you wanted nginx to issue a redirect.

Francis Daly        francis at

More information about the nginx mailing list