doufang8965 2017-02-06 22:55
浏览 40
已采纳

如何在codeigniter中的base_url()中添加index.php

In general when we use site_url() in anchor tag in php code it auto insert "index.php" before the controller like

/index.php/controllerName/methodName

But in base_url it doesn't insert "index.php". I want to add auto index.php before the controller how site_url() works.

Already I searched and understood that the change will be in config file. But want to know the specific answer what I need to change.

  • 写回答

1条回答 默认 最新

  • douzhan5262 2017-02-06 23:04
    关注

    Base URL should be absolute, including the protocol:

    $config['base_url'] = "http://somesite.com/somedir/";
    

    If using the URL helper, then base_url() will output the above string.

    Passing arguments to base_url() or site_url() will result in the following

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

    echo base_url('assets/stylesheet.css'); // http://somesite.com/somedir/assets/stylesheet.css
    echo site_url('mycontroller/mymethod'); // http://somesite.com/somedir/index.php/mycontroller/mymethod
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部