CodeIgniter 404找不到控制器

问题描述 投票:-1回答:3

我知道问题已被多次询问,但我真的无法解决问题。我的默认控制器正在工作,但如果我想访问另一个控制器,我将遇到404问题。

我的控制器文件名大写为Utilisateur.php,所以我试图通过inscription访问Controller函数<a href="Utilisateur/inscription">inscription</a>

这是我的配置:

$config['base_url'] = 'http://localhost:63342/WeBusy/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

这是我的根源:

$route['default_controller'] = 'accueil';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

最后控制器:

class Utilisateur extends CI_Controller {

    public function inscription(){
        $data = array('header' => 'HeaderAccueil.php', 'body' => 'utilisateur/AjoutUtilForm.php');
        $this->load->view('StructureHtml.php', $data);
    }

谢谢

php codeigniter http-status-code-404
3个回答
0
投票

提供锚点的完整路径

<a href="http://localhost:63342/WeBusy/Utilisateur/inscription">inscription</a>

但最好的做法是使用url helper或constants来提供动态url。

例如,如果使用url helper函数,你的锚点路径就像。

<a href="<?php echo site_url(); ?>Utilisateur/inscription">inscription</a>

不要忘记在自动加载文件或类构造函数中加载url helper。


0
投票

我找到了问题,所以我需要在应用程序的根目录中创建一个.htaccess文件,以便删除index.php,这仍然不能与phpstorm一起使用,也许有一些东西需要配置,但它工作顺利EasyPhp :)


0
投票
  1. 检查你的控制器文件名,应该是Utilisateur.php(ucfirst)。
  2. 检查你的mod_rewrite是否有效: http://localhost:63342/WeBusy/index.php?q=utilisateur/inscription 将新方法index(){die('test');}添加到您的Utilisateur控制器并更改$ route ['default_controller'] ='accueil'; to:$ route ['default_controller'] ='utilisateur';
© www.soinside.com 2019 - 2024. All rights reserved.