美文网首页
nginx配置thinkphp的pathinfo

nginx配置thinkphp的pathinfo

作者: 任人渐疏_Must | 来源:发表于2017-12-15 10:44 被阅读0次
    server {
        listen 80;
        server_name wxsearch.ngdna.com ;
        access_log /data/wwwlogs/access_nginx.log combined;
        root /data/wwwroot/wxsearch.ngdna.com;
        index index.html index.htm index.php;
        #error_page 404 /404.html;
        #error_page 502 /502.html;
        location /nginx_status {
          stub_status on;
          access_log off;
          allow 127.0.0.1;
          deny all;
        }
    
    location ~ \.php {
         root /data/wwwroot/wxsearch.ngdna.com;
            fastcgi_pass unix:/dev/shm/php-cgi.sock;
            fastcgi_index  index.php;
        ##先加载默认的fastcgi配置项
        include        fastcgi_params;
        ##正则解析路径,先使用set指令产生两个nginx变量并赋值
        ##此处先将$path_info值赋值为空
        set $path_info "";
        set $real_script_name $fastcgi_script_name;
        ##正则匹配URI,若能匹配将产生两个子组
        if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
            ##将两个子组赋值给刚生成的两个nginx变量
            set $real_script_name $1;
            set $path_info $2;
        }
        ##将可能匹配到的$path_info值通过fastcgi_param指令设置进去
        fastcgi_param PATH_INFO       $path_info;
        fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
        ##覆盖fastcgi_params文件中默认的SCRIPT_NAME配置项
        fastcgi_param SCRIPT_NAME     $real_script_name;
    }
    

    相关文章

      网友评论

          本文标题:nginx配置thinkphp的pathinfo

          本文链接:https://www.haomeiwen.com/subject/wbmrwxtx.html