Note the use of the Index,try_files directive
server {Listen 8803 default_server;
server_name test.php.360.cn;
Root/data/www/test;
Index index.html index.htm index.php;
Location/{
Try_files $uri $uri//index.php; #try_files will automatically remove the trailing slash
}
Location ~ \.php$ {
Try_files $uri = 404; #优化文件不存在的话提前报错, fascgi 404 File not found.
Include fastcgi.conf;
Fastcgi_pass 127.0.0.1:9000;
}
}
server {
Listen 80;
server_name yaf.com;
Root/home/acmer1183/yaf/public;
Index index.php index.html;
Access_log/data/nginx/logs/yaf.com.access.log;
Error_log/data/nginx/logs/yaf.com.error.log;
Rewrite ^/$/static/index.html last; #处理首页跳转
Rewrite/\. /deny last; #禁止访问隐藏文件
Location =/deny {
Deny all;
}
Location ^~/static/{
alias/home/acmer1183/yaf/static/;
Try_files $uri $uri/= 404;
}
Location ~ \.php$ {
Try_files $uri = 404;
Include fastcgi.conf;
Fastcgi_pass 127.0.0.1:9000;
}
Location/{
Try_files $uri $uri/index.php;
}
}