[英]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.