图片不存在则跳转
location /img_test {
root /var/www;
if ($request_filename ~ //var//www//img_test//(.*)) {
set $img_url $1;
set $error_html http://127.0.0.1/oa/images/$1;
}
error_page 404 $error_html;
index index.html index.htm index.php;
}
浏览文件
location /test_ {
root /var/www;
autoindex on;
}
php解析
location ~ /.php
{
root /var/www;
#if ( $uri ~ ^/huangshuai/ )
#{
# root /home/ihefe;
#}
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#include fastcgi_params;
}
php path_info
#set $path_info "";
#set $real_script_name $fastcgi_script_name;
#if ($fastcgi_script_name ~ "^(.+?/.php)(/.+)$") {
# set $real_script_name $1;
# set $path_info $2;
#}
#fastcgi_param SCRIPT_NAME $real_script_name;
#fastcgi_param PATH_INFO $path_info;
访问检测
location ~^/NginxStatus {
stub_status on;
access_log off;
}
补丁
if ($request_filename ~* (.*)/.php) {
set $php_url $1;
}
if (!-e $php_url.php) {
return 403;
}