为什么我的URI不起作用?

时间:2011-07-22 11:04:48

标签: php codeigniter

在我的routes.php中,我有:

$route['default_controller'] = "bitcoin";

在我的config.php中我有:

$config['base_url'] = 'http://localhost/bitcoin/';

$config['index_page'] = 'index.php';

这是我的控制器:http://www.pastie.org/2253458

当我尝试转到以下内容时,我找不到404(但404模板看起来不同):

http://localhost/bitcoin/edit/
http://localhost/bitcoin/index.php/edit

2 个答案:

答案 0 :(得分:2)

您不能通过默认控制器访问这些功能..假设您尝试访问另一个控制器。当没有传递任何东西时使用默认控制器,即:index.php

你需要去/bitcoin/index.php/bitcoin/edit

请注意,如果您有用于路由的htaccess文件设置,您将只能访问/ bitcoin / bitcoin / edit。

答案 1 :(得分:1)

你没有说你是否删除了.htaccess的索引,但如果你没有,你是否尝试使用:http://localhost/index.php/bitcoin

或者更好,因为它是你的默认控制器,只是http://localhost? 你正在做的事情很奇怪,我无法理解你是否在一个名为比特币的子文件夹中(以防它应该是http://localhost/bitcoin/来调用默认控制器,也称为比特币,但不是需要在您的网址中注明)。 如果您是root用户,则应将您的网址重写为:http://localhost/index.php/bitcoin/edit以调用默认控制器的edit()方法

修改

如果你在一个名为比特币的子文件夹中,你的基本网址,默认控制器应该是: http://localhost/bitcoin/(与http://localhost/bitcoin/index.php/bitcoin相同)

如果你想获得比特币方法edit(),应该是http://localhost/bitcoin/index.php/bitcoin/edit

另外,请尝试删除.htaccess AT ALL,看看会发生什么。

<强> EDIT2

哦,最后一件事:使用CI_Controller而不是CI_controller,如果你的操作系统中小写很重要,你可能会遇到一些问题