2014-10-06 63 views
5

在CodeIgniter的Fast-cgi环境中遇到mod_rewrite问题。我的.htaccess看起来像这样:如何在Fast-cgi中从codeigniter中删除index.php

DirectoryIndex index.php 
    RewriteEngine on 
    RewriteCond $1 !^(index\\.php|images|css|js|robots\\.txt|favicon\\.ico) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ /index.php?$1 [L] 

但是我得到一个错误'没有指定输入文件'。

我改

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^.* - [L] 

RewriteCond $1 !^(index\.php|images|robots\.txt) 
#RewriteRule ^(.*)$ /index.php?/$1 [QSA,L] 

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

<IfModule !mod_php5.c> 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

只用这一个也可以工作:

#RewriteRule ^(.*)$ /index.php?/$1 [QSA,L] 

我的问题是,我仍然有index.php文件的URL,如果我改变配置文件从$ config ['index_page'] ='index.php'的application/config/config.php;到$ config ['index_page'] ='';我有一个不同的错误。

我做错了什么?

+3

我发现了的application/config/config.php文件中的解决方案,我改变了$ config ['uri_protocol'] ='AUTO';到$ config ['uri_protocol'] ='REQUEST_URI'; – nandoC 2014-10-06 16:39:15

回答

0

在.htaccess

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

和config.php文件更改添加代码

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

$config['index_page'] = '';