【发布时间】:2013-02-22 05:25:14
【问题描述】:
当我将鼠标悬停或单击锚链接时,它会显示
http://localhost/code-testing/index.php/about-us.
我也试过 base_url() 和 site_url() 但结果是一样的。我怎样才能从 url 中删除那个 'index.php' ?
-谢谢。
已解决:
感谢大家的友好回答。我正在使用 xampp,这个对我有用
代码测试/应用程序/config/config.php
$config['base_url']= 'http://localhost/code-testing/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
代码测试/.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
然后以下链接可以正常工作,而不会在 url 中显示“index.php”
<li><a href="<?php echo base_url('home');?>">HOME</a></li>
<li><a href="<?php echo base_url('about_us');?>">About Us</a></li>
<li><a href="<?php echo base_url('contact');?>">Contact Us</a></li>
【问题讨论】:
-
但很抱歉,该帖子没有显示完整的方法。因为没有说 $config['uri_protocol'] = '?'; 应该写什么在 config.php 中,所以我没明白。
标签: codeigniter url