2012-03-31 83 views
3

第二个功能我是新CI中我有问题不能调用控制器笨

我用我的OS X Lion中,我用.htaccess我可以直接调用本地主机/ site_folder /它就像魅力,但我有第二个功能在我的控制器,但我不能直接这样调用本地主机/ site_folder /函数2

这里我控制器

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

该功能,它是说没有找到网址,为什么呢?

谢谢

+0

你可以把路线代码放在这里吗? ('config/routes.php') – safarov 2012-03-31 14:08:47

+0

如果My_Site不是你的默认控制器我想你需要通过'http:// localhost/site_folder/my_site/function2'调用它 – 2012-03-31 14:10:16

+0

@safarov这是我的'config/routes $ route [ 'default_controller'] = “myshop”' @Shiplu我已经尝试像你说的,但没有结果.. – ranggadablues 2012-04-02 02:12:55

回答

1

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

如果site_folder是您已经安装了CodeIgniter的文件夹,您的网址function2会,

http://localhost/site_folder/my_site/function2 
+0

我仍然无法从这里进入... 我的.htaccess 'RewriteEngine叙述在 的RewriteCond%{} REQUEST_FILENAME! -f RewriteCond%{REQUEST_FILENAME}!-d RewriteCond $ 1!^(index \ .php | images | robots \ .txt | css) RewriteRule ^(。*)$ index.php/$ 1 [L]' it是对的? – ranggadablues 2012-04-02 13:16:22

0
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';