krischao 发表于 2016-2-26 15:15:48

只能访问index.php,控制器404错误

本帖最后由 krischao 于 2016-2-26 16:10 编辑

无法访问控制器   http://localhost和localhost/index.php正常,首页可以正常加载


但访问任何控制器都是404
http://localhost/index.php/index   404错误!!

billyhan 发表于 2016-2-26 17:44:34

本帖最后由 billyhan 于 2016-2-26 17:46 编辑

http://localhost和localhost/index.php   在routes.php配置文件中,default_controller设置默认的控制器,默认的函数为index函数,所以http://localhost和localhost/index.php可以访问;你访问http://localhost/index.php/index 这个路径不对,应该是:http://localhost/index.php/index/函数名称;还有一种情况你的文件名和你php文件中的class类名不一致,类名要大写哈,比如文件叫index.php   文件里面是class Index{}

krischao 发表于 2016-2-26 17:46:50

本帖最后由 krischao 于 2016-2-26 17:49 编辑

billyhan 发表于 2016-2-26 17:44
http://localhost和localhost/index.php   在routes.php配置文件中,default_controller设置默认的控制器, ...
但访问其他控制器都是404,排除了几乎所有问题,就是无法访问 。、。。、这个工程之前是正常的,重新编译安装了一次apache,出了问题,又apt-get安装了一次apache,
结果就出了无法访问的问题

krischao 发表于 2016-2-26 17:51:08

billyhan 发表于 2016-2-26 17:44
http://localhost和localhost/index.php   在routes.php配置文件中,default_controller设置默认的控制器, ...

index是控制器,默认访问index方法
http://localhost可以访问到index控制器中的index方法,但其他方法和其他控制器都404

billyhan 发表于 2016-2-26 17:52:28

把错误信息打印出来 看下呢 error_reporting()

krischao 发表于 2016-2-26 17:57:54

billyhan 发表于 2016-2-26 17:52
把错误信息打印出来 看下呢 error_reporting()

没有任何错误信息

page2page 发表于 2016-2-26 19:12:40

可能是控制器文件名的问题,控制器文件名首字母大写!!试试吧。

xiaoajin 发表于 2016-8-8 22:42:13

我也是一样的问题,不过是nginx服务器,不知道楼主解决没,配起来好烦啊啊啊啊啊啊

狄拓 发表于 2017-7-6 16:02:47

xiaoajin 发表于 2016-8-8 22:42
我也是一样的问题,不过是nginx服务器,不知道楼主解决没,配起来好烦啊啊啊啊啊啊 ...

这很影响使用的积极性

狄拓 发表于 2017-7-6 16:37:45

狄拓 发表于 2017-7-6 16:02
这很影响使用的积极性

nginx 要修改配置文件,Nginx它不支持pathinfo
页: [1] 2
查看完整版本: 只能访问index.php,控制器404错误