php - 调用 Codeigniter 控制器方法不起作用
问题描述
我开始使用 CI 进行开发,我试图调用另一个我调用LOGIN
的控制器,但它让我收到错误“未找到”,而如果我将控制器放在 default_controller 中,它可以工作,我已经阅读了另一个论坛关于这个问题,但它不能解决我的情况,
class Login extends CI_Controller {
public function index() {
redirect("/welcome/index");
$this->load->view("login");
}
}
解决方案
Possible solutions 1. Please add .htaccess to the codigniter
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2. Can create a routing for login controller then you can call directly 3. Add $config['index_page'] = 'index.php'; in config.php
推荐阅读
- networking - 在重新启动之间保留内核 IP 路由表
- graph - GNN 层如何知道批次中的哪个图具有给定的节点和节点特征?
- typescript - How to move .env file into build folder with tsconfig
- spring-boot - 提高 spring 批处理作业性能
- visual-studio-code - 有没有办法在 VSCode 中禁用 shift + enter ?
- python-docx - 将图像插入现有 word 文件时文件损坏
- c# - IModelValidatorProvider 和 IModelValidator 实现的问题。生成的错误没有得到正确处理
- for-loop - 为什么这会在第二个循环中两次获得同一行?
- javascript - React-native 将组件添加到数组并访问它们
- c++ - 当其中一个函数实际上是函数对象时,修复或替代 ADL