繁体   English   中英

codeIgniter基本网址问题

[英]codeIgniter base url issue

嗨,我是codeigniter的新手,有链接形成的麻烦。 在我的页面中,我链接到另一页同样的<a href = "<?php base_url('feed');?>"><li>Feed Page</li></a>这里Feed是我的控制器之一。 但链接显示为http://localhost/BusinessPad/localhost/BusinessPad/feed ---实际上不存在。 无法理解这是怎么发生的。 我做了$ config ['index_page'] =''; 并添加.htaccess文件。

检查你在config.php文件中分配给base_url值,尝试site_url() ,更改:

<?php base_url('feed');?>

<?php echo site_url('feed'); ?>

你可以创建自己的标签,并像这样在href中插入一个网址

<a href="<?php echo site_url('controller/function/uri') ?>">Link</a>

或者如果你想帮助

您可以使用URL帮助程序生成标记

anchor(uri segments, text, attributes)

所以...使用它......

<?php echo anchor('controller/function/uri', 'Link', 'class="link-class"') ?>

用这个:-

<a href="<?php echo base_url('feed');?>">Link</a>

要么

<a href="<?php echo base_url().'feed';?>">Link</a>

要么

<a href="<?php echo base_url().'index.php/feed';?>">Link</a>
use this way
<a href = "<?php echo base_url();?>/index.php/feed">Feed Page</a>
or 
<a href = "<?= base_url() ;?>/index.php/feed">Feed Page</a>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM