meoujb 发表于 2014-9-2 20:11:21

codeigniter 路由问题

今天在练习学习官方给的例子时,使用以下方式路由到指定的页面
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,下面是配置信息。


#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;
      indexindex.php index.html index.htm ;
      rootD:/workspace;

      #charset koi8-r;
      #access_loglogs/host.access.logmain;

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

      #error_page404            /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_paramSCRIPT_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 {
      #    denyall;
      #}
    }


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

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


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_namelocalhost;

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

    #    ssl_session_timeout5m;

    #    ssl_protocolsSSLv2 SSLv3 TLSv1;
    #    ssl_ciphersHIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #      root   html;
    #      indexindex.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;

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


meoujb 发表于 2014-9-2 20:13:44

这是项目结构

adaaaaa 发表于 2016-3-9 10:13:10

是不是因为Pages.php 首字母要大写?
页: [1]
查看完整版本: codeigniter 路由问题