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条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作