【发布时间】:2012-03-08 19:59:04
【问题描述】:
我是 Codeigniter 的新手,使用 Codeigniter 1.7,我在根目录中创建了一个带有代码的 .htaccess 文件:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /ci/index.php/$1 [L]
从 url 中删除 index.php,并添加
$config['url_suffix'] = ".html";
到 config.php 文件为所有页面提供默认后缀。之后我用这段代码创建了一个控制器 test.php:
class Test extends Controller{
function test(){
parent::Controller();
}
function index(){
$this->load->view('test');
}
}
还有一个视图:
<?php
echo anchor(current_url(), 'This Page');
?>
当我导航到 http://localhost/ci/test.html 时,它工作正常,但是当我点击视图中由 anchor() 函数自动生成的链接时,它转到 http://localhost/ci/index.php/test.html
如何从 anchor() 函数生成的 url 中删除 /index.php/?
当我指向主页时
localhost/ci/index.html
它显示了一个 404 Page not found 错误,但是当我指向时
localhost/ci/index.php
它工作正常。为什么主页没有被转换为 index.html 而不是 index.php?
【问题讨论】:
标签: codeigniter