<div dir="ltr">It should work with underscores, hyphen&#39;s etc. as its grabbing all char&#39;s from the .+ that should match all char&#39;s that is not a line break.&nbsp;<div><br><div>Also about ignoring root. I set my root in the base of the server config. IE</div>
<div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;server {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;listen &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;80;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;server_name &nbsp; &nbsp; <a href="http://domain.org">domain.org</a> <a href="http://www.domain.org">www.domain.org</a>;</div><div><br>
</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;access_log &nbsp; &nbsp; &nbsp;/var/log/nginx/domain.org.access_log main;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;error_log &nbsp; &nbsp; &nbsp; /var/log/nginx/domain.org.error_log info;</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;root /var/www/<a href="http://domain.org/htdocs">domain.org/htdocs</a>;</div>
<div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;location ~ .*\.php$ {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_pass &nbsp; <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fastcgi_index &nbsp; index.php;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;location ~* ^.+\.(jpg|jpeg|gif|png)$ {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;access_log &nbsp; off;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;expires &nbsp; &nbsp; &nbsp;30d;</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>I try to keep everything at the lowest part that i need it. I use the index directive in the main http section as most of my sites will use those. And if i need custom then i will adjust in each of my server sections. Same thing with my server sections. i do a root in the toplevel of the server directive so everything works no matter what i do and then IF i need a location to go somewhere else i put that inside the location. I think this is easier and solves alot of issues of having to remember to put them in multiple location&#39;s etc etc. Only overwrite it if you need it.&nbsp;</div>
</div><div><div><br><div class="gmail_quote">On Sat, Sep 6, 2008 at 12:55 PM, David <span dir="ltr">&lt;<a href="mailto:mishy.cth@gmail.com">mishy.cth@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Rob,<br>
<br>
I&#39;ve managed to get this working now:<br>
<div class="Ih2E3d"><br>
 &nbsp; &nbsp; &nbsp; &nbsp;Location ~* ^.+\.(jpg|jpeg|gif|png)$ {<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;access_log &nbsp; &nbsp; &nbsp; &nbsp;off;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;expires &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 30d;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
</div>I needed to specify the root or it would default to nginx&#39;s default docroot.<br>
<br>
Your regex works well, but only works for images without underscores, hyphens,<br>
or anything infact that isn&#39;t just a continuous text string. Would it be easy<br>
enough to modify in order to cope with this ?<br>
<br>
<br>
</blockquote></div><br></div></div></div></div>