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

标签 .htaccess codeigniter fastcgi

在 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/

相关文章:

php - 在旧的 apache 安装上使用 PHP 5.3

php - 从虚拟/自定义 "web server"调用 PHP

apache - 替换URL查询字符串中的“/”以避免htaccess中出现404

.htaccess - Htaccess 重写规则(主页异常(exception))

.htaccess 单变量 url 重写

javascript - Codeigniter - 在 1 个 View 中显示来自 2 个不同模型函数的 2 个不同数据

php - ionauth 登录最大尝试次数实现

带有 FCGI 的 Apache 上的 Django - 高负载下 500 内部服务器错误

apache - WWW 到 NON WWW Urls(删除 WWW)使用 Apache (.htaccess)

php - 在 mysql 中运行更新查询后返回更新后的值