【问题标题】:cannot remove index.php in CodeIgniter application无法删除 CodeIgniter 应用程序中的 index.php
【发布时间】:2011-10-01 01:25:03
【问题描述】:

我正在部署我们在实时服务器中创建的 Web 应用程序,但是我在弄清楚如何删除 index.php 时遇到了麻烦。 我已经阅读了几篇关于如何在 codeigniter 应用程序中删除 index.php 的博客。

我已在我的 .htaccess 上尝试过此设置

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

在我的 config.php 上

$config['index_page'] = '';

$config['uri_protocol'] = 'REQUEST_URI';

但我仍然不知道如何删除它。我需要在 apache httpd.conf 中编辑一些东西吗?

谢谢!

【问题讨论】:

  • 你的 apache 服务器上启用了 mod_rewrite 吗?

标签: php apache codeigniter


【解决方案1】:

您可以尝试删除吗?出现在您的 .htaccess 中的 index.php 之后:

变化:

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

收件人:

RewriteRule ^(.*)$ /index.php/$1 [L]

【讨论】:

  • 我已将 .htaccess 更改为此设置 RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !- d RewriteRule ^(.*)$ index.php/$1 [L] 仍然没有任何反应
  • CodeIgniter网站上提到了以下设置:RewriteEngine onRewriteCond $1 !^(index\.php|images|robots\.txt)RewriteRule ^(.*)$ /index.php/$1 [L]
【解决方案2】:

这是我用的那个。尝试了 3 种不同的方法,然后才找到一种有效的方法

DirectoryIndex index.php
RewriteEngine on

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-17
    • 2016-04-21
    • 1970-01-01
    • 2013-08-09
    • 2012-12-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多