【问题标题】:htaccess errordocument not workinghtaccess错误文档不起作用
【发布时间】:2013-08-20 01:11:04
【问题描述】:

我的理解是,要显示自定义错误页面,必须放

ErrorDocument 404 /error/404.php

在 .htaccess 中

还有,

AllowOverride All

必须在 httpd.conf 文件中设置。但是,现在它设置为

AllowOverride None

如果我将 None 更改为 All,然后重新启动服务器,当我故意在地址栏中输入乱码时会收到 Internal Server Error 500。我做错了什么?

文件中的其他内容

IndexIgnore *

紧随其后

RewriteEngine on

遵循重写规则。

RewriteEngine on 是问题的原因——见下文。

【问题讨论】:

  • 您的 htaccess 文件中还有其他内容吗?
  • 在服务器的错误日志中查看确切的错误信息。
  • 所以我发现了错误日志:[Sat Aug 17 17:33:46 2013] [alert] [client 127.0.0.1] C:/Data/MyWeb/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration 我猜这是我在新 PC 上设置 Apache 时开始的,直到现在才注意到问题。该脚本以前有效。
  • @Gary 请删除您的问题或发送答案并标记它!
  • 答案是保证LoadModule rewrite_module modules/mod_rewrite.so在httpd.conf中没有注释

标签: apache .htaccess http-status-code-404 errordocument


【解决方案1】:

简答:此错误表示您忘记启用rewrite 模块并且与ErrorDocument 无关。

如何解决?

确保您已启用rewrite 模块。这可以通过执行以下操作之一来完成:

  1. 在 Apache 配置文件中取消注释 LoadModule rewrite_module modules/mod_rewrite.so
  2. 以 root 身份运行 a2enmod rewrite仅在基于 Debian 的系统上可用)。

为什么在添加 ErrorDocument 后才出现此错误?

AllowOverride 设置为 None,这意味着您的 .htaccess 将被完全忽略。稍后,您将其设置为 All 以启用 .htaccess 文件。

但是,您忘记启用 rewrite 模块,但您尝试在 .htaccess 中使用它。这与ErrorDocument 无关,纯属巧合。您发布的以下错误清楚地显示了它:

[Sat Aug 17 17:33:46 2013] [alert] [client 127.0.0.1] C:/Data/MyWeb/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-09
    • 1970-01-01
    • 2012-06-22
    • 2011-08-31
    • 1970-01-01
    • 2018-07-22
    • 2013-04-14
    • 2013-07-18
    相关资源
    最近更新 更多