try_files and expires

Francis Daly francis at daoine.org
Wed Dec 9 16:31:06 UTC 2015


On Tue, Dec 08, 2015 at 03:34:28PM +0100, rainer at ultra-secure.de wrote:

Hi there,

>     location / {
>         # First attempt to serve request as file, then as directory,
> then fall back to index.php
>         try_files $uri $uri/ /website/var/assets/$uri /index.php?$args;
>         index index.php;
>     }
> 
> So, there are "assets" (pdfs, mostly but also some images) in a
> subdirectory.
> 
> This works, but this directive:
> 
>     location ~* \.(jpe?g|gif|png|bmp|ico|css|js|pdf|zip|htm|html|docx?|xlsx?|pptx?|txt|wav|swf|avi|mp\d)$
> {
>         access_log off;
>         log_not_found off;
> 
>         expires 1w;
>     }
> 
> breaks the first directive.
> 
> Is there a way to have both?

One request is handled in one location. Put the configuration that you
want, in the location that is matched.

It is not immediately clear to me what response you want for a request
for /one.pdf.

Perhaps add the try_files to the regex location?

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list