Welcome! Log In Create A New Profile

Advanced

How to Set Expires With Try Files

Joshua Pearce
May 20, 2011 01:12AM
Below is my config file. How can I change the two "if" blocks to try_files, and still do a 30d expires for static files?

server {
listen 80;
server_name www.joshpearce.org;
client_max_body_size 4M;
access_log /var/log/nginx/localhost.access.log;

# root of website *exactly*, use '=' for speed
location = / {
root /var/www/joshpearce.org;
index index.php index.html index.htm;
}
location / {
root /var/www/joshpearce.org;
index index.php index.html index.htm;
if (-f $request_filename) {
expires 30d;
break;
}
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
}
# use: htpasswd - htpwds NewUser NewPassword
location ^~ /info {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpwds;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/usr/local/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/joshpearce.org$fastcgi_script_name;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/usr/local/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/joshpearce.org$fastcgi_script_name;
}

#error_page 404 /404.html;
}

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

How to Set Expires With Try Files

Joshua Pearce May 20, 2011 01:12AM

Re: How to Set Expires With Try Files

Igor Sysoev May 20, 2011 01:38AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 202
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