【发布时间】:2014-09-22 23:03:17
【问题描述】:
在我的 codeigniter 项目中,我正在使用 htaccess 从 url 中删除 index.php 扩展名。现在,当我尝试调用索引文件夹中的函数/页面时,例如:http://domain.com/project/index/contactus,它显示404 Page Not Found Error。
我的htaccess文件如下图:
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule \.htaccess - [F]
RewriteRule (.*)(css\/)(.*)$ $2$3 [QSA,L]
RewriteCond %{request_uri} !^index\.php
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
索引控制器:
class Index extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url','timezone_helper'));
$this->load->library('tank_auth');
$this->load->library('session');
timezone();
}
function index()
{
$this->load->view('index/index');
}
function contactus()
{
$data['email']=$this->config->item('webmaster_email', 'tank_auth');
$data['page']='index/contactus';
$this->load->view('layout/template',$data);
}
}
谁能帮我找到这个问题的解决方案?
提前致谢。
【问题讨论】:
-
一些服务器配置使应用程序只能像
index.php?/$1这样工作,但您也可以尝试index.php/$1。告诉我们结果。另外,向我们展示来自控制器的代码。 -
我将
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]更改为RewriteRule ^(.*)$ index.php/$1 [QSA,L],但出现页面未找到错误。 -
控制器呢?它在哪里?
-
请检查我更新的问题。
-
网址
http://domain.com/project/index/index有效吗?
标签: php apache .htaccess codeigniter mod-rewrite