丁老头 发表于 2017-3-17 13:43:09

ngingx访问根目录下的文件无误,但是访问ci框架中的内容就404

nginx配置文件
#usernobody;
worker_processes1;

#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;

#pid      logs/nginx.pid;


events {
    worker_connections1024;
}


http {
    include       mime.types;
    default_typeapplication/octet-stream;

    #log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_loglogs/access.logmain;

    sendfile      on;
    #tcp_nopush   on;

    #keepalive_timeout0;
    keepalive_timeout65;

    #gzipon;

    server {
      listen       80;
      server_namelocalhost;

      location / {
            root   d:/www;
            indexindex.php index.html index.htm;

          autoindex on;
      }

      error_page   500 502 503 504/50x.html;
      location = /50x.html {
            root   html;
      }

      # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
      #
      location ~ \.php$ {
            root         d:/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_indexindex.php;
            fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
            include      fastcgi_params;
      }
    }
}


直接访问d:/www下的index.php文件可以输出内容,但是访问这个www目录下的ci文件夹中D:\www\ci\application\controllers\cnews控制器文件中的read_news()方法不起作用。别的使用CI框架做的别的项目也是无法访问。就只能访问http://127.0.0.1/index.php或者http://127.0.0.1/index.html这样的结构的文件,别的都不行。


求大神帮忙看下,百度了也没找到结果

Closer 发表于 2017-3-17 15:00:44

1. 你 CI 訪問的 URL 路徑是 ?
2. 你預設的路由控制器是 ?
3. $config['base_url'] 的設定為 ?

Hex 发表于 2017-3-17 23:03:54

nginx 配置请先参考 nginx 官方 CI 配置 https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/
页: [1]
查看完整版本: ngingx访问根目录下的文件无误,但是访问ci框架中的内容就404