嗨,我是代码点火器的新手,在链接形成方面遇到了问题。在我的页面中,我有另一个与<a href = "<?php base_url('feed');?>"><li>Feed Page</li></a>
相同的页面的链接这里的提要是我的一个控制器。但链接显示为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中插入一个url,如下所示
<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>