0

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

ErrorDocument 404 /error/404.php

在.htaccess

还,

AllowOverride All

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

AllowOverride None

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

文件中的其他内容

IndexIgnore *

其次是

RewriteEngine on

其次是重写规则。

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

4

1 回答 1

0

Short answer: This error means you forgot to enable the rewrite module and is not related to ErrorDocument.

How to fix it?

Make sure you have enabled the rewrite module. This can be done by doing one of the following:

  1. Uncommenting LoadModule rewrite_module modules/mod_rewrite.so in your Apache configuration file.
  2. Run a2enmod rewrite as root (only available on Debian-based systems).

Why are you only getting this error after you added ErrorDocument?

AllowOverride was set to None, which means your .htaccess will be completely ignored. Later, you set it to All to enable .htaccess files.

However, you forgot to enable the rewrite module but you tried to use it in your .htaccess. This is not related to ErrorDocument and is simply a coincidence. The following error you posted is clearly showing it:

[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

于 2013-09-27T16:19:52.700 回答