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

codeigniter 路由问题

[复制链接]
发表于 2014-9-2 20:11:21 | 显示全部楼层 |阅读模式
今天在练习学习官方给的例子时,使用以下方式路由到指定的页面
http://localhost/Codeigniter/index.php/pages/view/about

出现
404 Page Not Found错误,
A PHP Error was encounteredSeverity: Warning
Message:  Missing argument 1 for Pages::view()
Filename: controllers/pages.php
Line Number: 4


我使用的是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;
        index  index.php index.html index.htm ;
        root  D:/workspace;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;

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

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
        location /Codeigniter/index.php {
            fastcgi_pass   127.0.0.1:9000;
            include        fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME    D:/workspace/Codeigniter/index.php;
          }
        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
            expires      30d;
        }
        location ~ .*\.(js|css)?$ {
            expires    12h;
        }
            
        
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

路由配置信息:
$route['default_controller'] = 'pages/view';
$route['404_override'] = '';

$route['(:any)']='pages/view/$1';

config.php中的配置信息:
$config['uri_protocol']    = 'AUTO';
$config['enable_query_strings'] = FALSE;

搞了一天了,一直无法路由到指定的页面,求指教!!!!


 楼主| 发表于 2014-9-2 20:13:44 | 显示全部楼层
这是项目结构
QQ图片20140902201448.jpg
发表于 2016-3-9 10:13:10 | 显示全部楼层
是不是因为Pages.php 首字母要大写?

本版积分规则