我知道问题已被多次询问,但我真的无法解决问题。我的默认控制器正在工作,但如果我想访问另一个控制器,我将遇到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);
}
谢谢
提供锚点的完整路径
<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。
我找到了问题,所以我需要在应用程序的根目录中创建一个.htaccess文件,以便删除index.php,这仍然不能与phpstorm一起使用,也许有一些东西需要配置,但它工作顺利EasyPhp :)