douhei8633
douhei8633
2017-10-13 07:41
浏览 61
已采纳

为什么在codeigniter中没有正确生成此链接?

I'm using codeigniter and the link to my categories don't work right. Maybe I don't understand some settings of the framework. I have in my configuration file set this base url:

$config['base_url'] = 'http://hms.loc';

But when I click the "Home" category or any other category the link looks like:

http://localhost/hms/

But it should be:

http://hms.loc

When I click the "Rooms" category it is:

http://localhost/hms/rooms

How do I set this up correctly? And where can I specify such settings?

图片转代码服务由CSDN问答提供 功能建议

我正在使用codeigniter并且指向我的类别的链接无法正常工作。 也许我不理解框架的一些设置。 我在配置文件中设置了这个基本URL:

  $ config ['base_url'] ='http://hms.loc'; 
  <  / pre> 
 
 

但是当我单击“主页”类别或任何其他类别时,链接如下所示:

  http:// localhost / hms /  
   
 
 

但它应该是:

  http://hms.loc 
  <  / pre> 
 
 

当我点击“房间”类别时,它是:

  http:// localhost / hms / rooms 
    
 
 

如何正确设置? 我在哪里可以指定这样的设置?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • douhuo1738
    douhuo1738 2017-10-13 07:45
    已采纳

    You can use base_url() or site_url() method from URL_Helper.

    Please check the documentation:

    https://www.codeigniter.com/user_guide/helpers/url_helper.html

    点赞 评论
  • drqefnd544707688
    drqefnd544707688 2017-10-13 07:45

    I use xampp, my web app folder name is "s_v", so i using

    $config['base_url'] = 'http://localhost/s_v/';
    
    点赞 评论
  • dqd78456
    dqd78456 2017-10-13 07:57

    If your project folder name is hms , define base_url as

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

    Other wise check in html contain

    <base href="http://localhost/hms/">
    
    点赞 评论

相关推荐