3

我是codeigniter的新手我有问题

我使用我的 OS X Lion,我使用.htaccess我可以直接调用 localhost/site_folder/ 它就像魅力一样,但我的控制器中有第二个函数,但我不能像 localhost/site_folder/function2 那样直接调用该函数

这是我的控制器

class My_site extends CI_Controller {
function __construct() {
  parent::__construct();
  }
function index() {
  --some script--
  }
function function2() {
  --some script--
  }
}

它说找不到网址,为什么?

谢谢你

4

4 回答 4

1

默认路由方案是example.com/class/function/id/ Doc

如果site_folder是您安装 codeigniter 的文件夹,您的网址function2将是,

http://localhost/site_folder/my_site/function2
于 2012-03-31T14:13:11.857 回答
1

我在这个论坛上找到了解决方案http://ellislab.com/forums/viewthread/210578/

于 2012-04-02T13:45:31.097 回答
1
  It may be the issue please Check the uri protocol in the config file that should be AUTO.

  Config/config.php ===> $config['uri_protocol']    = 'AUTO';
于 2014-09-11T09:06:10.320 回答
0

根据Mushi , codeigniter 会自动将 index.php 添加到 config.php 文件中指定的“localhost/site_folder/”(第 38 行)。所以要调用这个函数,你必须去'localhost/site_folder/index.php/function2'

于 2019-07-25T21:50:16.450 回答