<div dir="ltr">Thank you for advice!<div>I will add the "redirect".</div><div><br></div><div>Nevertheless I wonder why the following (almost similar) config works?</div><div>I get php output when requesting for <a href="http://site.com//files/imagecache/small/1.jpg">http://site.com//files/imagecache/small/1.jpg</a><br></div><div>Though rewrite goes to another location with some additional parameters the configurations looks to me similar to one in the first message.</div><div><br></div><div>Config that works(nginx 1.8):</div><div><br></div><div><div>location ~ (\.php$|\.php/|\.php\?) {</div><div><span style="white-space:pre">      </span>fastcgi_pass  <a href="http://127.0.0.1:9002">127.0.0.1:9002</a>;</div><div><span style="white-space:pre">      </span>fastcgi_index  index.php;</div><div><span style="white-space:pre">    </span>include        fastcgi_params;</div><div><br></div><div><span style="white-space:pre">   </span>set $path_info "";</div><div><span style="white-space:pre">  </span>set $real_script_name $fastcgi_script_name;</div><div><span style="white-space:pre">   </span>if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {</div><div><span style="white-space:pre">    </span>   set $real_script_name $1;</div><div><span style="white-space:pre">        </span>   set $path_info $2;</div><div><span style="white-space:pre">       </span>}</div><div><span style="white-space:pre">     </span>fastcgi_param SCRIPT_FILENAME  $document_root$real_script_name;</div><div><span style="white-space:pre">      </span>fastcgi_param SCRIPT_NAME $real_script_name;</div><div><span style="white-space:pre">  </span>fastcgi_param PATH_INFO $path_info;</div><div><span style="white-space:pre">   </span>fastcgi_param PATH_TRANSLATED $document_root$real_script_name;</div><div>}</div><div>location /files/imagecache {</div><div><span style="white-space:pre">     </span>root   /.mnt/www-sfedu-data;</div><div><span style="white-space:pre">        </span>try_files $uri @imagecache;</div><div>}</div><div>location /files {</div><div><span style="white-space:pre">   </span>root   /.mnt/www-sfedu-data;</div><div>}</div><div>location @imagecache {</div><div><span style="white-space:pre">   </span>rewrite ^/files/imagecache/(.*)$ /php_j/imagecache/index.php?q=$1;    #no permanent or redirect here !</div><div>}</div></div><div><br></div><div><br></div><div>Thank you in advance!</div><div>Regards,</div><div>Alexander Trofimchouk</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-12-15 16:18 GMT+03:00 Francis Daly <span dir="ltr"><<a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Dec 15, 2017 at 03:48:20PM +0300, Alexander Trofimchouk wrote:<br>
<br>
Hi there,<br>
<span class=""><br>
> My nginx rewrite works only if I add "permanent" directive. Without it there<br>
> is no rewrite seen even in browser's network log.<br>
<br>
</span><a href="http://nginx.org/r/rewrite" rel="noreferrer" target="_blank">http://nginx.org/r/rewrite</a><br>
<br>
"rewrite" does not directly lead to "http redirect" without specific<br>
configuration.<br>
<span class=""><br>
> For example: User requests <a href="http://site.com/files/imagecache/thumb/1.jpg" rel="noreferrer" target="_blank">http://site.com/files/<wbr>imagecache/thumb/1.jpg</a>,<br>
> Nginx tries to find the file or redirects to<br>
> <a href="http://site.com/www2/web/app_dev.php/image/cache?path=thumb/1.jpg" rel="noreferrer" target="_blank">http://site.com/www2/web/app_<wbr>dev.php/image/cache?path=<wbr>thumb/1.jpg</a><br>
<br>
</span>No, that's not what your config says.<br>
<br>
nginx *rewrites* to /www2/web/app_dev.php/images/<wbr>cache?path=thumb/1.jpg<br>
<br>
That rewritten request (depending on the omitted config) probably is<br>
handled within<br>
<span class=""><br>
  location ~ ^/www2/web/(app_dev|config)\.<wbr>php(/|$) {<br>
<br>
</span>which does the fastcgi_pass to PHP.<br>
<br>
If you want nginx to *redirect*, you have to tell it to, using one of<br>
the three documented methods.<br>
<br>
> If I add "permanent" I get Symfony controller output in browser - which is<br>
<span class="">> OK. What did I do wrong?<br>
<br>
</span>You left off "permanent" or "redirect" or didn't start the replacement<br>
string with "http://", if you wanted nginx to issue a redirect.<br>
<span class="HOEnZb"><font color="#888888"><br>
        f<br>
--<br>
Francis Daly        <a href="mailto:francis@daoine.org">francis@daoine.org</a><br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br>
</font></span></blockquote></div><br></div>