Php 控制器/方法路由上的CodeIgniter 404错误
我现在面临一个关于CodeIgniter的小问题 我有以下文件:Php 控制器/方法路由上的CodeIgniter 404错误,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我现在面临一个关于CodeIgniter的小问题 我有以下文件: applications/controllers/home/entretiens.php 看起来是这样的: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Entretiens extends CI_Controller { public function index() {
applications/controllers/home/entretiens.php
看起来是这样的:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Entretiens extends CI_Controller
{
public function index()
{
if($this->session->userdata('logged_in'))
{
$data['page'] = "entretiens";
$session_data = $this->session->userdata('logged_in');
$data['prenom'] = $session_data['prenom'];
$this->load->model("Entretiens_model");
$data['entretiens'] = $this->Entretiens_model->getAllEntretiens($session_data['id']);
$data['main_content'] = 'home/entretiens_view.php';
$this->load->template('entretiens_view', $data);
}
else
{
//If no session, redirect to login page
redirect('home/login', 'refresh');
}
}
public function ajouter()
{
echo 'Test';
}
}
?>
还有config.php
(好吧,有趣的部分):
和我的.htaccess
:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ ./index.php/$1 [L]
(此问题发生在所有控制器上,而不仅仅是
入口
…更改routes.php中的相关行,如下所示:
$route[“entrieens(.*)]]=“home/entrieens$1”;
这将被视为通配符,在entertiens
之后的所有内容都将传递到home/entertiens
中,效果非常好!感谢您的帮助!
$config['base_url'] = 'http://dev.hinsolite.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond $1 !^(index\.php|css|images|robots\.txt)
RewriteRule ^(.*)$ ./index.php/$1 [L]