我在访问页面或控制器时遇到问题,确切地说是在codeigniter中。默认控制器工作正常,但当我创建一个新控制器时,它无法访问,当我超过url http://localhost/codeigniter/admin/login
时,它显示错误404 Page not Found。这是我的控制器代码,位于Codeigniter/applications/controllers/admin/Login.php 中
if (!defined('BASEPATH')) {
exit('No direct script access allowed');
}
class Login extends CI_Controller
{
public function index()
{
$data = array(
'title' => 'Login Administrator',
'isi' => 'admin/login_view'
);
$this
->load
->view('admin/login_view', $data)
;
}
}
这是我的配置代码:
$config['base_url'] = 'http://localhost/codeigniter/';
$config['index_page'] = 'index.php';
这是我的.htaccess文件,位于根文件夹(CodeIgniter)中
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
我使用的是本地服务器XAMPP,我确实启用了重写模块,将httpd.conf AllowOverride None更改为AllowOverwrite All,但仍然无法工作。我陷入了困境,所以请帮忙:)谢谢。
您的.htaccess不工作。如果你试图点击这个网址
http://localhost/codeigniter/index.php/admin/login
其工作,有关如何从codeigniter url中删除"index.php"的更多详细信息,可以参考http://theprofessionguru.com/question/remove-indexphp-from-url-in-codeingiter