How to set base url in codeigniter

岁酱吖の 提交于 2020-01-07 12:30:10

问题


I have codeigniter project and I want to upload in local server :192.168.x.xxx.

But I don't know how to change base_url in config file from localhost to local server contain IP address. How to set $config['base_url'] ? Thanks


回答1:


I would set it some thing like

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

With domain

$config['base_url'] = 'http://www.yourdomainname.com/';

End base url with /

If you don't set the base url links and css, images etc will not work properly.




回答2:


try it like this :

index.php :

define('APP_URL', ($_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . "://{$_SERVER['SERVER_NAME']}".str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']));

config.php :

$config['base_url'] = APP_URL;

reference : How to set proper codeigniter base url?




回答3:


Try like this:

$config['base_url'] = 'http://192.168.3.107/pkl2017';  

NOTE: pkl2017 is your project folder name.



来源:https://stackoverflow.com/questions/45450302/how-to-set-base-url-in-codeigniter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!