CodeIgniter 从 2.2.0 升级到 3.0.x:只有默认控制器正在加载

CodeIgniter upgrade from 2.2.0 to 3.0.x: Only the default controller is loading

我通常 post 不会在网上发消息寻求帮助,但我觉得我已经尝试了所有方法,但还是卡住了。

我想将 CodeIgniter 从 2.2 版本升级到 3.0.3 版本(我也尝试过 v3.0.2),然后按照相应的 guide on codeigniter.com 进行操作。但是现在,无论 url.

只加载默认控制器

我在网上搜索了一下,发现可能来自:

但是我还是没有解决办法...

一定是路由问题...

以下是我做过的一些测试: 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  !^(index\.php|public|images|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/ [L]
    

这是我的 "application/config/routes" 文件:


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

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

谢谢!


解决方案

$config['enable_query_strings'] 在文件 "application/config/config.php" 中设置为 "TRUE"。将它设置为 "FALSE" 解决了这个问题。就这么简单...

在 codeigniter 3 wamp 中

我用这个 htaccess

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

由于你的错误 404 over ride 不能在子文件夹中。

改变

$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';

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

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

试试这个

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

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