为什么我的uri不能工作?



在我的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

你不能像这样通过默认控制器访问函数。它假设您试图访问另一个控制器。默认控制器在不传递任何参数时使用,例如:index.php

你需要进入/bitcoin/index.php/bitcoin/edit

注意,如果你有一个htaccess文件设置路由,你将只能去/bitcoin/bitcoin/edit。

你没有说你是否已经删除了索引。htaccess,但如果你没有,你试过使用:http://localhost/index.php/bitcoin吗?

或者更好,因为它是你的默认控制器,只有http://localhost ?你所做的很奇怪,我无法理解你是否在一个名为比特币的子文件夹中(在这种情况下,它应该是http://localhost/bitcoin/来调用默认控制器,这也被称为比特币,但不需要在你的URL中指出)。如果您在根目录下,您应该将url重写为:http://localhost/index.php/bitcoin/edit以调用默认控制器

edit()方法编辑:

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

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

同时,试着删除你的。htaccess,看看会发生什么。

Edit2

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

最新更新