登陆

phpstudy 切换nginx环境下访问项目提示404,找不到文件

phpstudy 切换nginx环镜 以url路由方式访问 ''域名/控制器/方法''  提示404,找不到文件

解决方法:

server {

        listen       80;

        server_name www.tp5.io;

        root   "D:/phpStudy/PHPTutorial/WWW/tp5/public";

        location / {

            index  index.html index.htm index.php;

            #autoindex  on;

            #手动添加伪静态

            if (!-e $request_filename) {

                rewrite  ^(.*)$  /index.php?s=$1  last;

                break;

            }

        }

        location ~ \.php(.*)$ {

            fastcgi_pass   127.0.0.1:9000;

            fastcgi_index  index.php;

            fastcgi_split_path_info  ^((?U).+\.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;

        }

}

₉₄₇₉₄₇2019-11-27 17:05:45556 次浏览

全部回复(2)我要回复

  • phpsutdy-爱好者

    phpsutdy-爱好者2019-11-28 09:15:45

    修改伪静态规则 ,隐藏index.php 

    回复
    0
  • ₉₄₇

    ₉₄₇2019-11-27 17:09:59


    server {

            listen       80;

            #虚拟域名

            server_name  www.tp5.io;

            #项目路径

            root   "D:/phpStudy/PHPTutorial/WWW/tp5/public";

            location / {

                index  index.html index.htm index.php;

                #autoindex  on;

                #手动添加伪静态

                if (!-e $request_filename) {

                    rewrite  ^(.*)$  /index.php?s=$1  last;

                    break;

                }

            }

            location ~ \.php(.*)$ {

                fastcgi_pass   127.0.0.1:9000;

                fastcgi_index  index.php;

                fastcgi_split_path_info  ^((?U).+\.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;

            }

    }

    回复
    0
  • 取消回复发送