【问题标题】:Unable to Remove index.php on ExpressionEngine WAMP Installation无法在 ExpressionEngine WAMP 安装中删除 index.php
【发布时间】:2012-06-11 21:24:51
【问题描述】:

我在我的 Windows 7 机器上安装了 WAMP v2.2,并启用了虚拟主机。

我已经为我的一个本地站点成功安装了 ExpressionEngine,并且一切正常,除非我尝试使用 approved .htaccess method 从 URL 中删除 index.php。如果index.php 不存在,我仍然会收到 404 错误,但页面显示正常,URL 中有index.php

我确保在 Apache 菜单中检查了重写模块:
。这个方法我在商业主机上成功用过几十次了,难住了。

pvledoux 更新:

<IfModule mod_rewrite.c>
  RewriteEngine On

  # Removes index.php
  RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]

  # If 404s, "No Input File" or every URL returns the same thing
  # make it /index.php?/$1 above (add the question mark)
</IfModule>

注意:我尝试将? 添加到规则中,但没有成功。

该站点位于虚拟主机的根目录。

【问题讨论】:

标签: .htaccess windows-7 wamp expressionengine


【解决方案1】:

您是否检查过 Apache 中的默认文档?如果您要从机器上物理删除 index.php,并且它仅在一个目录 www.domain.com/home/ 上报告 404,这意味着 Apache 仍在寻找 index.php。

【讨论】:

  • 嗨乔希,你是说我应该删除 index.php 作为默认文档吗?我试过了,没有效果。我也试过只注释掉整个命令,但这也没有用。
  • @kgrote 你在哪里设置 Apache 的默认文档?如果您显示您在 Apache 中的默认设置,我们应该能够检测到问题所在。
  • 这是默认情况下规则的样子:&lt;IfModule dir_module&gt; DirectoryIndex index.php index.php3 index.html index.htm &lt;/IfModule&gt; 更新后:&lt;IfModule dir_module&gt; DirectoryIndex index.php3 index.html index.htm &lt;/IfModule&gt; 文件位于C:/wamp/bin/apache/Apachex.xx.x/conf/httpd.conf
  • @kgrote 你确定 dir_module 已经安装了吗?
【解决方案2】:

mod_rewrite turned on 在 Apache 中吗?

【讨论】:

    【解决方案3】:

    尝试添加 RewriteBase /

    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase / 
    
      # Removes index.php
      RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ /index.php/$1 [L]
    
      # If 404s, "No Input File" or every URL returns the same thing
      # make it /index.php?/$1 above (add the question mark)
    </IfModule>
    

    并确保 mod_rewrite 在 phpinfo 中处于活动状态

    【讨论】:

      【解决方案4】:

      您可以在这里尝试以下几种可能性:

      [...]
      RewriteEngine On
      Options FollowSymLinks
      [...]
      

      或者:

      [...]
      RewriteEngine On
      Options +MultiViews
      [...]
      

      或者:

      [...]
      RewriteEngine On
      Options FollowSymLinks
      Options +MultiViews
      [...]
      

      根据我的经验,Apache 在 Windows 上运行时通常需要其中一项或两项才能正确执行此类操作。你也可能直接涨 500,但这些过去对我有用。

      【讨论】:

        【解决方案5】:

        知道了!

        我需要在 httpd-vhosts.conf 中添加 AllowOverride:

        <Directory "C:\Site\Root\Path">
            AllowOverride All
            Order Deny,Allow  
            Allow from all
        </Directory>
        

        感谢@parhamr 帮助我摆脱这种泡菜,感谢您和 6 包啤酒。

        【讨论】:

        • 这对我来说适用于 Vagrant 和 ExpressionEngine
        猜你喜欢
        • 2016-10-09
        • 1970-01-01
        • 2013-08-15
        • 2012-08-09
        • 1970-01-01
        • 2011-10-28
        • 1970-01-01
        • 2016-04-21
        • 1970-01-01
        相关资源
        最近更新 更多