dongrendang6566 2018-01-21 12:09
浏览 30
已采纳

CodeIgniter 404不是页面

I'm just learning CI, but I've encountered the following problem. I created a controller home.php with class home (the size of letters is the same). The controller loads the view home_view.

In config.php, I have the following parameters:

config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

routes.php:

$route['default_controller'] = 'home/index';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

.htaccess file

DirectoryIndex home.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./home.php/$1 [L,QSA]

Where do I make a mistake?

  • 写回答

2条回答 默认 最新

  • donkey111111 2018-01-22 17:11
    关注

    It seems in your .htaccess file you redirect all callbacks to file home.php, instead of default CI's default index file, and this home.php does not exists (as you said it's a controller, and it should be in controllers folder)

    htaccess should be like this:

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
    

    This way, is index.php file from codeigniter who loads all requierd files (config, routes, etc) and calls the controller specified in config.php file.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?