首页 文章

CodeIgniter从2.2.0升级到3.0.x:仅加载默认控制器

提问于
浏览
2

我通常不会在网上发布消息以获得帮助,但我觉得我已经尝试了所有内容而且我被卡住了 .

我想将CodeIgniter从2.2版升级到3.0.3版(我也试过了v3.0.2),然后我跟着相应的guide on codeigniter.com . 但现在,只有默认控制器被加载,无论网址如何 .

我在网上搜索过,我发现它可能来自:

  • htaccess

  • application / config / config文件

  • application / config / routes文件

  • 文件名的新Ucfirst规则(控制器,模型......)

但我仍然没有解决方案......

  • "applications/controllers"中的文件都是Ucfirst .

  • 之前一切正常(使用2.2版),因此应该正确配置WAMP(启用mod_rewrite等...) . 此外,我已经尝试并成功加载了一个干净的CodeIgniter 3实例 .

  • Models, Controllers and Views are loaded correctly, I can change my default controller and it will load the correct view (with requests done by controllers and models). But it only loads the default controller, no matter what the url is (in the browser). Even if it does not exist, I never have the 404 page. Except if I specify an incorrect "default_controller" (in the file "routes.php").

它必须是路由问题......

Here is some of the tests I have done: Table of tests

这是我的htaccess文件(我也尝试过网上的其他文件,结果是一样的):

RewriteEngine On

    #Checks to see if the user is attempting to access a valid file,
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #Enable access to the images and css folders, and the robots.txt file
    RewriteCond $1 !^(index\.php|public|images|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [L]

这是我的“application / config / routes”文件:

$route['default_controller'] = 'dashboard';
    $route['404_override'] = 'auth/e404';
    $route['translate_uri_dashes'] = FALSE;

任何帮助,将不胜感激 :-)

Thank you !


SOLUTION

$config['enable_query_strings'] was set to "TRUE" in the file "application/config/config.php". Setting it to "FALSE" solved the issue. So simple...

2 回答

  • 0

    尝试将索引方法放在路由中,例如,而不是这样

    $route['blog'] = 'blog';
    

    试试这个

    $route['blog'] = 'blog/index';
    

    如果这不起作用,你能确认你在application / config / config.php中设置了正确的基本URL吗?

  • 0

    在codeigniter 3 wamp

    我用这个htaccess

    Options +FollowSymLinks
    Options -Indexes
    DirectoryIndex index.php
    RewriteEngine on
    RewriteCond $1 !^(index\.php|images|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    

    随着您的错误404超越骑不能在子文件夹中 .

    更改

    $route['404_override'] = 'auth/e404';
    

    $route['404_override'] = 'e404';
    

    在config.php上

    $config['base_url'] = 'http://localhost/your_project/';
    
    // You can leave base url blank but not recommended because when you try to submit forms make cause issue.
    
    $config['index_page'] = '';
    
    $config['uri_protocol'] = 'REQUEST_URI';
    

相关问题