【发布时间】:2011-08-27 10:33:35
【问题描述】:
我正在尝试让此 URL 用于安装 codeigniter,今天刚刚安装了最新版本 (2.0.2):
http://mydomain.com/pete/ci_test/accounts
所以我在 routes.php 中将我的默认控制器设置为 test.php,在我的控制器 test.php 中,我有以下代码:
class test extends CI_Controller {
public function index() {
$this->load->view('test');
}
public function accounts() {
$this->load->view('accounts');
}
}
然后我的视图中有一个 test.php 和一个 accounts.php,当我转到 http://mydomain.com/pete/ci_test/ 时它会加载 test.php 视图
但是当我转到http://mydomain.com/pete/ci_test/accounts 时,它给了我一个 404。我一直在阅读入门,它说“默认情况下 CodeIgniter 使用基于段的方法”,然后给出了一个类似于我的示例正在做。但后来我进一步阅读它说:“默认情况下,index.php 文件将包含在您的 URL 中”。所以我将此添加到我的 htaccess 文件中(位于 mydomain.com/pete/ci_test/.htaccess):
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
我确保模块在 httpd.conf 中加载。它仍然没有进入我的 accounts.php 视图。我也试过:
http://mydomain.com/pete/ci_test/index.php/accounts
但是另一个 404,我做错了什么?任何建议都会有所帮助,谢谢!
【问题讨论】:
标签: .htaccess codeigniter