• 关于Thinkphp访问不正常的问题


    最近遇见了个蹩脚的问题,我放在服务器的项目(thinkphp框架)只能访问默认路径内容,不管你url怎么写的,他就访问默认那个文件..

    对于有强迫症的我来说实在是欺人太甚!!!

    于是乎我就抓耳挠腮了...

    说一下我的服务,php7.0 +nginx+ mysql +Linux(ubuntu)

    由于不知问题出在哪里,所以排查起来很费劲

    首先,把项目放在本地和服务器分别试了一下,本地没毛病,线上全毛病,额,这说明项目木得问题

    然后,设置一下文件权限,有读写权限即可,这个命令就不用说了吧,可以度

    接下来还不行,那就是配置的原因了

    nginx配置文件

    /etc/nginx/conf.d/的conf文件

    内容如下:

    server {
        listen       80;
        server_name  wp.***.com;
        root /workspace/home;
        index  index.html index.htm index.php;
        error_page  404              /404.html;
        location = /404.html {
            return 404 'Sorry, File not Found!';
        }
        error_page  500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/share/nginx/html; 
        }
        location / {
            try_files $uri @rewrite;
        }
        location @rewrite {
            set $static 0;
            if  ($uri ~ .(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css.map|min.map)$) {
                set $static 1;
            }
            if ($static = 0) {
                rewrite ^/(.*)$ /index.php?s=/$1;
            }
        }
        location ~ /Uploads/.*.php$ {
            deny all;
        }
        location ~ .php/ {
           if ($request_uri ~ ^(.+.php)(/.+?)($|?)) { }
           fastcgi_pass 127.0.0.1:9000;
           include fastcgi_params;
           fastcgi_param SCRIPT_NAME     $1;
           fastcgi_param PATH_INFO       $2;
           fastcgi_param SCRIPT_FILENAME $document_root$1;
        }
        location ~ .php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        location ~ /.ht {
            deny  all;
        }
    }

    这个配置文件挺全的,完美支持普通,兼容,pathinfo,rewrite4种url模式,别怪我没提醒你收藏哦. 常见的静态文件404时也不会再去跑一遍fastcgi浪费资源。

    恩,完美解决。哈哈哈哈哈哈

  • 相关阅读:
    汉诺塔3(递推)
    逃生(拓扑排序)
    洛谷P2048 [NOI2010]超级钢琴 (优先队列+RMQ)
    有条件的最短路
    hdu 5950 Recursive sequence(矩阵快速幂)
    线性基模板
    P2023 [AHOI2009]维护序列 (线段树区间修改查询)
    hdu 6534 Chika and Friendly Pairs(莫队+树状数组)
    2019 计蒜之道 复赛
    poj 2449 k短路(A*+spfa)
  • 原文地址:https://www.cnblogs.com/guaiyouyisi/p/7905171.html
Copyright © 2020-2023  润新知