【问题标题】:Codeigniter remove index.php on Apache/2.2.15 (Red Hat) serverCodeigniter 删除 Apache/2.2.15 (Red Hat) 服务器上的 index.php
【发布时间】:2015-03-11 14:27:55
【问题描述】:

我有一个问题,我使用一个 .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'] = 'AUTO';

同样的代码正在另一台服务器上运行

【问题讨论】:

    标签: codeigniter


    【解决方案1】:

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

    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>
    

    【讨论】:

    【解决方案2】:
    1. 在http.conf中加载“mod_rewrite.so”;
    2. 将 AllowOverride “None”替换为“All”
    3. 在 .htaccess 中尝试这些代码:

    【讨论】:

    • 抱歉我看不懂第一步和第二步
    • step1 意味着您必须在使用之前打开重写模块。只需编辑 apache 配置文件 - “http.conf”,并删除此行之前的“#” - “LoadModule rewrite_module module/mod_rewrite.so”,然后重新启动服务器。
    【解决方案3】:
    1. 确保您已从 apache 启用 mode_rewrite,您可以运行 debian 服务器 a2enmod rewrite

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

    Htaccess

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

    祝你好运:)

    【讨论】:

      【解决方案4】:

      使用以下代码:

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

      希望对你有帮助。

      【讨论】:

        猜你喜欢
        • 2014-11-25
        • 1970-01-01
        • 2021-10-05
        • 1970-01-01
        • 2011-08-10
        • 2018-01-27
        • 2014-01-07
        • 2013-09-04
        • 2011-07-18
        相关资源
        最近更新 更多