thinkphp5 nginx配置 安全pathinfo版本

Posted Technofiend

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了thinkphp5 nginx配置 安全pathinfo版本相关的知识,希望对你有一定的参考价值。

server
    
        listen 80;
        server_name tp.com www.tp.com;
        index index.html index.htm index.php;
        root  /home/wwwroot/thinkphp/public/;

        location / 
            if (!-e $request_filename) 
                rewrite ^(.*)$ /index.php$1 last;
                break;
            
        

        location ~ ^(.+\\.php)(.*)$ 
            # try_files $uri =404;
            fastcgi_pass unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;

            include fastcgi_params;
            fastcgi_split_path_info ^(.+\\.php)(\\/?.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;

            # 强制将某些非法地址交给 index.php 处理
            set $new_fastcgi_script_name $fastcgi_script_name;
            if (!-e $document_root$fastcgi_script_name) 
                set $new_fastcgi_script_name "/index.php";
             

            fastcgi_param SCRIPT_FILENAME $document_root$new_fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $new_fastcgi_script_name;
        

        location /nginx_status
        
            stub_status on;
            access_log   off;
        

        location ~ .*\\.(gif|jpg|jpeg|png|bmp|swf)$
        
            if (!-e $request_filename) 
                rewrite ^/(uploads/.*)$ /pic.php?$1 last;
            
            expires      30d;
        

        location ~ .*\\.(js|css)?$
        
            expires      12h;
        

        location ~ /\\.
        
            deny all;
        
    

以上是关于thinkphp5 nginx配置 安全pathinfo版本的主要内容,如果未能解决你的问题,请参考以下文章

Nginx下ThinkPHP5的配置方法详解

nginx+thinkphp5配置

lnmp1.4 nginx配置thinkphp5

CentOS7 Nginx ThinkPHP5.1 配置

centos6.8 环境一键安装包 nginx配置thinkphp5

ThinkPHP5 Nginx通用配置