用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1896|回复: 2
收起左侧

[版本 2.x] ngingx访问根目录下的文件无误,但是访问ci框架中的内容就404

[复制链接]
发表于 2017-3-17 13:43:09 | 显示全部楼层 |阅读模式
nginx配置文件
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

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

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   d:/www;
            index  index.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_index  index.php;
            fastcgi_param  SCRIPT_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这样的结构的文件,别的都不行。


求大神帮忙看下,百度了也没找到结果
发表于 2017-3-17 15:00:44 | 显示全部楼层
1. 你 CI 訪問的 URL 路徑是 ?
2. 你預設的路由控制器是 ?
3. $config['base_url'] 的設定為 ?
发表于 2017-3-17 23:03:54 | 显示全部楼层
nginx 配置请先参考 nginx 官方 CI 配置 https://www.nginx.com/resources/ ... ecipes/codeigniter/

本版积分规则