I want to use custom error file for 403 but apache just seems to ignore the directive ErrorDocument
and just gives me the default error document. Here's the beginning of my httpd.conf
ServerRoot "C:/xampp/apache"
Listen 80
ErrorDocument 403 "/403.html"
ErrorDocument 404 "/403.html"
I just added 404
to see if it would work, it didn't. The file 403.html
exists inC:\xampp\apache\403.html
I tried moving the ErrorDocument
directive further down in the configuration file, where comments describing ErrorDocument
directive start but the result was the same.
I do not have ErrorDocument
directives in any .htaccess
files in folders that I'm testing.
Can you please tell me why apache is ignoring me?
Just to be sure I will mention the way I'm testing this. I have a .htaccess
file in C:\xampp\htdocs
with the following contents
Order deny,allow
Allow from 127.0.0.1
Allow from ::1
Deny from all
The purpose of which is to deny access to all subfolders and files that don't explicitly allow it, and then I'm just sending a request to my public IP to get access denied.
The first place to look in case of any error are the logs/error.log
and logs/access.log
logfiles of your apache installation.
As the documentation at http://httpd.apache.org/docs/2.2/mod/core.html#errordocument states, this directive is relative to the DocumentRoot
of your current host configuration.
You are not using a default Apache HTTPD but instead the preconfigured Apachefriends XAMPP which has some specialties e.g. the standard httpd.conf
coming with XAMPP references the ErrorDocument
s via
# Multi-language error messages
Include conf/extra/httpd-multilang-errordoc.conf
In the default httpd.conf
your DocumentRoot
is C:\apache\htdocs
so with your above mentioned changes (namely ErrorDocument 403 "/403.html"
) in your httpd.conf
, you will have to place those files into C:\xampp\htdocs\403.html
.
As an aside it is usually a good idea to separate your custom configuration by adding an Include conf/my-custom.conf
to httpd.conf
and adding your config in there.