wdcp nginx pathinfo rewrite 设置

作者: 健隆 分类: 服务器 发布时间: 2019-03-27 13:42

wdcp的nginx设置 使其支持pathinfo和隐藏index.php 



server {
        listen       80;
        root /www/web/test;
        server_name www.test.com;
        index  index.html index.php index.htm;
        error_page  400 /errpage/400.html;
        error_page  403 /errpage/403.html;
        error_page  404 /errpage/404.html;
        error_page  503 /errpage/503.html;
        location ~ .php(.*)$ {
                fastcgi_pass  unix:/tmp/php-55-cgi.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;
                fastcgi_param PATH_INFO $2;
                include fcgi.conf;
				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 ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ {
                expires      1d;
        }
        location ~ .*.(js|css|html|htm)?$ {
                expires      12h;
        }
        location ~ /.ht {
                deny  all;
        }
        location / {
                 try_files $uri $uri/ /?$args;
        }
        if (!-e $request_filename) {
		   rewrite  ^(.*)$  /index.php?s=$1  last;
		   break;
		}
}

 

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!