Welcome! Log In Create A New Profile

Advanced

Re: Question about nested locations / PHP.

March 09, 2012 07:50PM
On Fri, 2012-03-09 at 22:12 +0000, Adrian Hayter wrote:
> Not sure if this is the right place to post this; apologies in advance if it is!
>
> I'm having a bit of trouble with nested locations and PHP. I have a
> setup where I want all PHP files to go through fastcgi, and have an
> expiry of epoch. However, one particular PHP file is used to generate
> CSS stylesheets, and I want this file to have an expiry of 30 days. My
> current code looks like this:
>
> location ~ \.php$
> {
> location ~ /css.php
> {
> expires 30d;
> add_header Pragma public;
> add_header Cache-Control "public";
> }
>
> expires epoch
>
> // Fastcgi stuff...
> }
>


You don't need nested locations. This should work:

location = /css.php {
expires 30d;
add_header Pragma public;
add_header Cache-Control "public";
include fastcgi_params;
fastcgi_pass ...
}

location ~ \.php$ {
expires epoch
include fastcgi_params;
fastcgi_pass ...
}

Information on the order of processing can be found here:

http://nginx.org/en/docs/http/request_processing.html#simple_php_site_configuration
http://wiki.nginx.org/HttpCoreModule#location



Regards,
Cliff



> Thanks in advance!
>
> Adrian
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Question about nested locations / PHP.

Tiberius March 09, 2012 05:14PM

Re: Question about nested locations / PHP.

Cliff Wells March 09, 2012 07:50PM

Re: Question about nested locations / PHP.

Tiberius March 09, 2012 08:42PM

Re: Question about nested locations / PHP.

Maxim Dounin March 10, 2012 04:18PM

Re: Question about nested locations / PHP.

Cliff Wells March 10, 2012 05:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 277
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready