为什么这个链接在codeigniter中没有正确生成?
问题描述:
我正在使用codeigniter,并且指向我的类别的链接无法正常工作。也许我不明白框架的一些设置。我在设定这个基础URL我的配置文件:为什么这个链接在codeigniter中没有正确生成?
$config['base_url'] = 'http://hms.loc';
但是,当我点击“主页”类别或任何其他类别的链接看起来像:
http://localhost/hms/
但它应该是:
http://hms.loc
当我点击了 “房间” 类别是:
http://localhost/hms/rooms
如何正确设置?我在哪里可以指定这样的设置?
答
您可以使用URL_Helper的base_url()
或site_url()
方法。
请查看文档:
https://www.codeigniter.com/user_guide/helpers/url_helper.html
答
我用XAMPP,我的web应用程序文件夹名称为 “S_V”,所以我使用
$config['base_url'] = 'http://localhost/s_v/';
答
如果你的项目文件夹名称为HMS, define base_url as
$config['base_url'] = 'http://localhost/hms/';
其他明智的检查在html中包含
<base href="http://localhost/hms/">
检查您是如何创建链接的。你应该使用'url helper' – urfusion
你能告诉我们你的代码为这些hrefs吗? – hungrykoala
我用过'