【问题标题】:404 error in index.php/user but not is index.phpindex.php/user 中的 404 错误,但不是 index.php
【发布时间】:2017-07-06 13:46:03
【问题描述】:
创建 .htaccess 文件后找不到 404 页面。已经检查配置文件,启用重写模式。索引文件显示 blog/index.php 正在工作,但 index.php/user 没有。已经检查了 user.php。这是 user.php 的代码
(使用 codeigniter)
<?PHP
class User extends MY_Controller{
}
echo "user file in controller for public";
?>
这是输出
公共控制器中的用户文件
404 页面未找到
找不到您请求的页面。
【问题讨论】:
标签:
php
apache
.htaccess
codeigniter
【解决方案1】:
您是否设置了默认控制器?
$route['default_controller'] = 'MY_Controller';
或者那样做
【解决方案2】:
使用以下代码将您的控制器保存为User.php。
<?PHP
class User extends MY_Controller
{
public function index()
{
echo "user file in controller for public";
}
}
?>
【解决方案3】:
Codeigniter change log 说
更改的文件命名约定(类文件名现在必须是 Ucfirst
以及其他所有小写字母)。
所以你的控制器和文件名应该是
- My_controller(仅 M 大写其余小写)
- Public_controller
- Application_controller
- Foo_controller
类用户扩展 MY_Controller{ }
所以你的文件名必须是User.php
即:文件名=类名