<div dir="ltr">That's because the latter regex location takes precedence over the /static one.<div>You should first decide if that regex location should also includes /static prefix or not.</div><div>If it's a yes, then you should also add the same rewrite-rule inside your regex location, if it's a not, you can turn your /static location to also use regex like this<br></div><div><br></div><div>location ~ ^/static/ {</div><div># rewrite here...</div><div>}</div><div><br></div><div>So nginx will take a look at that location first when you request for /static/* urls.</div><div><br></div><div>Another way is to use `try_files`, but then you should probably create another (internal) location block to do the rewrite.</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 18, 2015 at 2:49 AM, Karl Johnson <span dir="ltr"><<a href="mailto:karljohnson.it@gmail.com" target="_blank">karljohnson.it@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<br><br>I host a website based on Laravel with Nginx 1.6.2 + PHP-FPM 5.6. Most images on the website are in /static folder and are served to visitors with a PHP file (see /static location).<br><br>I want to add a 30 days expire on all images of this vhost. However, when I add the "location ~* \.(?:image)$ {" rule to add expire, the rewrite for images in /static doesn't work anymore. Nginx reports file not found for all images in /static.<br><br>Any idea how to make it works? <br><br>Vhost configuration below:<br><br>server {<br>        listen 80;<br>        server_name <a href="http://www.website.com" target="_blank">www.website.com</a>;<br>        root /home/www/<a href="http://website.com/public_html/public" target="_blank">website.com/public_html/public</a>;<br>        access_log /var/log/nginx/website.com-access_log;<br>        error_log /var/log/nginx/website.com-error_log warn;<br><br>        location /static {<br>                rewrite ^/static/images/([0-9])\-([0-9]+)x([0-9]+)/(.*)$ /image-f7ec13d.php?zc=$1&w=$2&h=$3&src=../uploads/images/$4;<br>        }<br><br>## not working, break the rewrite images above<br>#<br>#       location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff)$ {<br>#                expires 30d;<br>#                add_header Cache-Control "public";<br>#       }<br><br>        include conf.d/custom/restrictions.conf;<br>        include conf.d/custom/pagespeed.conf;<br>        include conf.d/custom/fpm-laravel.conf;<br><br>        pagespeed DisableFilters combine_css;<br>}<br><br><br>Rewrite not working after adding the location for all images expire:<br><br>2015/03/17 13:46:12 [error] 11792#0: *12217 openat() "/home/www/<a href="http://website.com/public/static/images/0-0x0/2015/03/2015-03-10-media-fr.jpg" target="_blank">website.com/public/static/images/0-0x0/2015/03/2015-03-10-media-fr.jpg</a>" failed (2: No such file or directory)<br><br><br><br>Regards,<br><br>Karl<br></div>
<br>_______________________________________________<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" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">regards,<br>Nurahmadie<br>--<br></div>
</div>