如何从Fast-cgi中的codeigniter中删除index.php

nan*_*doC 5 .htaccess codeigniter fastcgi

在Code_gniter的Fast-cgi环境中遇到mod_rewrite问题.我的.htaccess看起来像这样:

    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] 
Run Code Online (Sandbox Code Playgroud)

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

我换了

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>
Run Code Online (Sandbox Code Playgroud)

它也适用于这个:

#RewriteRule ^(.*)$ /index.php?/$1 [QSA,L]
Run Code Online (Sandbox Code Playgroud)

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

我做错了什么?

小智 1

在.htaccess中添加代码

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

和 config.php 文件更改

$config['index_page'] = 'index.php';
Run Code Online (Sandbox Code Playgroud)

$config['index_page'] = '';
Run Code Online (Sandbox Code Playgroud)