Correct way to serve static files ?

Daniel Dourvaris dourvaris at gmail.com
Mon Oct 19 23:55:56 MSD 2009


On Mon, Oct 19, 2009 at 8:11 PM, George <nginx-forum at nginx.us> wrote:

> I've been looking over lots of nginx configurations and the way to serve
> static files differed slightly, so which is the correct way as i've seen the
> following syntax
>
>        location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
>
> vs
>
>        location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico)$ {
>
> what's the difference between the 2 ?
>

Read up on regexs, these are both similar in that they match urls ending in
(jpg, jpeg etc.)
However there is one tiny difference, the first one requires there be a dot
before the extension, whereas the second doesn't, eg. it should match
"/somethingjpg" whereas the first would only match "/something.jpg"

The second one looks wrong, it probably wanted to be location ~*
^.+\.(jpg|jpeg|gif|css|png|js|ico)$ {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20091019/f1920c72/attachment.html>


More information about the nginx mailing list