Codeigniter删除Apache / 2.2.15(Red Hat)服务器上的index.php

时间:2015-01-13 15:18:38

标签: codeigniter

我有一个问题我使用一个.htaccess文件表单一年这个代码在所有服务器上工作但今天我有一个新服务器相同的代码不工作。我无法从URL中删除index.php。我的服务器是Apache / 2.2.15(Red Hat)。 我的.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,QSA] 
<IfModule mod_headers.c>
Header add Cache-Control:  "no-store, no-cache, must-revalidate"
</IfModule>

在配置文件中,我设置了以下设置

$ config ['index_page'] =''; $ config ['uri_protocol'] ='自动';

此代码正在另一台服务器上运行

4 个答案:

答案 0 :(得分:0)

你可以尝试这样:(但我不确定)

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

我也在使用Apache。我的.htaccess:

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

<Files "index.php">
AcceptPathInfo On
</Files>

答案 1 :(得分:0)

  1. 加载&#34; mod_rewrite.so&#34;在http.conf;
  2. 替换AllowOverride&#34;无&#34;与&#34;所有&#34;
  3. 在.htaccess中尝试这些代码: enter image description here

答案 2 :(得分:0)

  1. 确保您从apache启用了mode_rewrite,debian服务器可以运行a2enmod rewrite

  2. 尝试下面的htaccess,当我遇到同样的问题时,它对我有用

  3. 的.htaccess

    <IfModule mod_rewrite.c>
    Options +FollowSymLinks
     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
    </IfModule>
    

    Goodluck:)

答案 3 :(得分:0)

使用以下代码:

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

我希望这会对你有所帮助。

相关问题