CI 框架访问 http://[::1]/yourproject/

Chances are you have left the base url blank
/* |-------------------------------------------------------------------------- | Base Site URL |-------------------------------------------------------------------------- | | URL to your CodeIgniter root. Typically this will be your base URL, | WITH a trailing slash: | | http://example.com/ | | WARNING: You MUST set this value! | | If it is not set, then CodeIgniter will try guess the protocol and path | your installation, but due to security concerns the hostname will be set | to $_SERVER['SERVER_ADDR'] if available, or localhost otherwise. | The auto-detection mechanism exists only for convenience during | development and MUST NOT be used in production! | | If you need to allow multiple domains, remember that this file is still | a PHP script and you can easily do that on your own. | */ $config['base_url'] = '';


Go to application/config/config.php set base_url

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

Then ::1 error should be gone.

 

Now days in latest versions of codeIgniter it is not recommend that you leave your base_url blank.

  • $config['base_url'] = 'http://localhost/yourproject/';
  • $config['base_url'] = 'http://www.example.com/';

And is always good to end url with /

 

 

二:此原因及升级版本后,CodeIgniter-3.0.6\system\core\Config.php 构造函数体内  $_SERVER['SERVER_ADDR']  造成,改成 $_SERVER['HTTP_HOST'],做相应调整亦可。

posted @ 2016-10-18 11:54  冷暖自知一抹茶ck  阅读(565)  评论(0编辑  收藏  举报