codeigniter:删除index.php不起作用

时间:2013-12-11 15:25:12

标签: codeigniter

我正在尝试从url中删除index.php。但它没有用!

使用ubuntu 12.04(LAMP)。

CodeIgniter_2.1.2

.htaccess文件

<IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteBase /cms1



        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ index.php/$1 [L] 
    </IfModule>

在config.php中:

$config['index_page'] = 'index.php'; to $config['index_page'] = '';

目录结构:

/var/www/cms1

->cms1
    ->application
    ->system
    ->user_guide
    ->index.php
    ->license.txt
    ->.htaccess

3 个答案:

答案 0 :(得分:4)

答案 1 :(得分:3)

的.htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

在你的applications / config / config.php

$config['base_url'] = 'http://www.yourwebsite.com'; //url to your project
$config['index_page'] = ''; //Needs to be empty

答案 2 :(得分:0)

项目根目录.htaccess文件替换为以下包含。

RewriteEngine on 
RewriteBase /your-project-directory-name/ 
RewriteCond $1 !^(index.php|resources|robots.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA]