在 CodeIgniter 的 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]
但是我收到错误消息“未指定输入文件”。
我改为
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]
我的问题是,如果我将配置文件 application/config/config.php 从 $config['index_page'] = 'index.php'; 更改为 URL 上的 index.php;到 $config['index_page'] = '';我有一个不同的错误。
我做错了什么?
最佳答案
在 .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'] = '';
关于.htaccess - 如何从 Fast-cgi 中的 codeigniter 中删除 index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26220635/