<div dir="ltr">It should work with underscores, hyphen's etc. as its grabbing all char's from the .+ that should match all char's that is not a line break. <div><br><div>Also about ignoring root. I set my root in the base of the server config. IE</div>
<div><div> server {</div><div> listen 80;</div><div> server_name <a href="http://domain.org">domain.org</a> <a href="http://www.domain.org">www.domain.org</a>;</div><div><br>
</div><div> access_log /var/log/nginx/domain.org.access_log main;</div><div> error_log /var/log/nginx/domain.org.error_log info;</div><div><br></div><div> root /var/www/<a href="http://domain.org/htdocs">domain.org/htdocs</a>;</div>
<div><br></div><div> location ~ .*\.php$ {</div><div> fastcgi_pass <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;</div><div> fastcgi_index index.php;</div>
<div> }</div><div><br></div><div> location ~* ^.+\.(jpg|jpeg|gif|png)$ {</div><div> access_log off;</div><div> expires 30d;</div><div> }</div>
<div> }</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's etc etc. Only overwrite it if you need it. </div>
</div><div><div><br><div class="gmail_quote">On Sat, Sep 6, 2008 at 12:55 PM, David <span dir="ltr"><<a href="mailto:mishy.cth@gmail.com">mishy.cth@gmail.com</a>></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've managed to get this working now:<br>
<div class="Ih2E3d"><br>
Location ~* ^.+\.(jpg|jpeg|gif|png)$ {<br>
access_log off;<br>
expires 30d;<br>
}<br>
<br>
</div>I needed to specify the root or it would default to nginx's default docroot.<br>
<br>
Your regex works well, but only works for images without underscores, hyphens,<br>
or anything infact that isn'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>