2016-11-08 05:44 阅读 191

如何在codeigniter中的config.php文件中设置config_base url?

I am beginner in Codeigniter. I have downloaded the software and tried to configure it. How can I configure a base url to use in codeigniter?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

5条回答 默认 最新

  • 已采纳
    dt102282 dt102282 2016-11-08 05:53

    You should got to this file path


    Search for this line that contains

    $config['base_url'] = ""

    Then your base_url should be

    $config['base_url'] = "http://yoursite.com/"

    If xampp, it should be

    $config['base_url'] = "http://localhost/yoursite/"

    And if wamp, it should be

    $config['base_url'] = "http://www/yoursite/"

    Note that yoursite is the filename of the site folder you have in htdocs or www folder

    When you make use of <?php echo base_url(directory/file_name); ?> In your views, it should output something like:


    That should do the trick

    点赞 评论 复制链接分享
  • dongmeng2509 dongmeng2509 2016-11-08 05:45

    Go to application/config , open config.php and put value in this variable

    $config['base_url'] = '';
    点赞 评论 复制链接分享
  • dpfwhb7470 dpfwhb7470 2016-11-08 05:45

    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 assuming

    $config['index_page'] = "index.php";
    点赞 评论 复制链接分享
  • douchensi8625 douchensi8625 2016-12-11 15:53

    Note: Following solutions is detailed provided you have setup your localhost on your machine successfully.

    Both the points as mentioned above will work. Like, you can set the Base URL value for your corresponding setting of localhost or you can set it to EMPTY.

    1. Setting as Empty (Simple and Elegant)

      $config['base_url'] = '';

    The Codeigniter version simply autodetects the base_url of your current project.

    But in CI version it's NOT supported anymore. You have to explicitly declare you projects Base URL.

    1. Configuring the path to your Project Directory. The following procedure is when you setup your localhost using xampp in Windows or using default Apache's configuration folder in Linux i.e var/www/html/your_project_directory.

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

    2. Using nginx configuration in Linux or wamp in Windows

      $config['base_url'] = "http://www/your_project_directory/"

    点赞 评论 复制链接分享
  • duanmei1930 duanmei1930 2017-04-28 04:55

    if you are running your project in local-server like Xamp or wamp then you can set the base url like this $config['base_url']=""; or you can also set $config['base_url']="http://host/yoursite"

    点赞 评论 复制链接分享