wdlinux nginx低版重写问题

wdlinux 环境使用 nginx 时,重写的配置是有问题的,比如说 thinkphp5 的重写,配置完成后还是 404

正确的配置 Nginx demo 如下

80 端口

server {
        listen       80;
        root /www/web/test/public_html;
        server_name 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_split_path_info  ^(.+\.php)(.*)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;   
                include fcgi.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
            #主要是这一段一定要确保存在
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=$1  last;
                break;
            }
            #结束
            #autoindex  on;
        }
}

443 端口

server {
        listen       443;
        root /www/web/test/public_html;
        ssl                  on;
        ssl_certificate      cert/test.com.crt;
        ssl_certificate_key  cert/test.key;
        ssl_prefer_server_ciphers on;
        ssl_session_timeout 10m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
        server_name 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_split_path_info  ^(.+\.php)(.*)$;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                fastcgi_param  PATH_INFO  $fastcgi_path_info;
                fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
                include        fastcgi_params;   
                include fcgi.conf;
        }
        location ~ /\.ht {
                deny  all;
        }
        location / {
            #主要是这一段一定要确保存在
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=$1  last;
                break;
            }
            #结束
            #autoindex  on;
        }
}

修改完配置之后一定要重启 nginx

 /www/wdlinux/nginx/sbin/nginx -s reload

 

给TA支持
共{{data.count}}人
人已支持
工作日志

PHP Redis 锁参考脚本

2019-10-8 11:21:11

工作日志

宝塔 php7.2 安装 mcrypt

2020-6-24 14:40:16

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索