【问题标题】:Apache Mod_ReWrite Suddenly Stopped WorkingApache Mod_ReWrite 突然停止工作
【发布时间】:2011-07-06 14:51:30
【问题描述】:

我在我的服务器上设置了 mod_rewrite 来重写如下网址

http://www.example.com/1

http://www.example.com/index.php?show=1

换句话说,URL 会缩短。当系统在我的开发站点的子域下运行时,一切正常,但现在它只生成一个 Not Found 错误,尽管如果我手动输入 url /index.php?show=1 它工作正常。

所以唯一的变化是从

切换的 url

http://www.site.example.com

http://www.site.com

但是它仍然在同一服务器上运行,并且服务器上 public_html 内的同一子文件夹只是新域名已指向该文件夹。

它所在的文件夹是/public_html/paste

目录中运行的完整.htaccess文件是

# Set Default File
DirectoryIndex index.php

# Turn ReWrite Engine On
RewriteEngine on

# Create Rule To Write URLs To Shorter Versions
RewriteRule /([a-z0-9]+) /index.php?show=$1

我无法启用 RewriteLog,因为主机出于某种原因不允许它。

【问题讨论】:

  • 你确定你的主机有 mod_rewrite 并且允许 htaccess 覆盖吗?
  • 正如我所说,当通过子域访问时它工作得很好,但只有在我用它自己的域设置它时才失败。它仍在同一服务器、帐户和同一主机上运行。另外,我还在该服务器上运行了另一个站点,它完美地使用了 mod_write。

标签: apache mod-rewrite


【解决方案1】:

听起来AllowOverride 指令没有为该文件夹正确设置。在您的 Apache 配置中,您应该确保您用于主域的目录或 Vhost 将 AllowOverride 设置为 All

http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride

【讨论】:

  • 试过这个解决方案和上面的那个,但似乎都没有帮助。根据我的主机 mod_rewrite 工作正常,它一定是站点配置的问题,但我已经搜索了我的配置并且没有任何错误。正要尝试从同一目录进行一些简单的其他重写,所以看看它是 mod_rewrite 问题还是站点配置问题
【解决方案2】:

您可能需要指定 RewriteBase 指令。

http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritebase

我还要注意Options +FollowSymlinks 也可以放在里面,以防你在配置链的上游关闭它(没有它重写将无法工作)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-22
    • 2021-02-01
    • 2016-12-29
    • 2018-05-09
    • 2015-12-07
    • 2015-08-23
    • 2014-02-05
    相关资源
    最近更新 更多