thinkphp pathinfo nginx 无法加载模块:I

2019-12-11  本文已影响0人  一位先生_

无法加载模块:Index.php
错误位置
FILE: /var/multrix/wxactivity_archive/ThinkPHP/Library/Think/Dispatcher.class.php  LINE: 177

其实就是域名后跟index.php/admin/index/index (去掉index.php是可以访问的,存在就不行)
最后经过几番折腾,才知道是pathinfo的原因

  1. 框架配置文件作出修改
    config.php中设置
/* URL配置 */
'URL_CASE_INSENSITIVE' => true, // 默认false 表示URL区分大小写 true则表示不区分大小写
'URL_MODEL' => 2, // URL模式

nginx.conf 设置

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root 项目目录;
    index index.html index.htm index.php;

    # Make site accessible from http://localhost/
    server_name 域名或ip地址;
   


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

    location ~ .+\.php($|/) {
        set $script    $uri;
        set $path_info  "/";
        if ($uri ~ "^(.+\.php)(/.+)") {
            set $script     $1;
            set $path_info  $2;
         }
             
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index  index.php?IF_REWRITE=1;
        include fastcgi_params;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param SCRIPT_FILENAME  $document_root/$script;
        fastcgi_param SCRIPT_NAME $script;
    }
}

就这些改动 亲测可用 希望能帮到你们!

上一篇下一篇

猜你喜欢

热点阅读