1

So, I'm having a challenge trying to get my virtual hosts (in the example, called bozo) to 'point' at the right error documents for 401, 403,... errors. I am trying the following construct, but it doesn't seem to work:

 <VirtualHost <ip.address.here> ServerAdmin [email protected] DocumentRoot /home/www/htdocs/virtual/bozo ServerName www.bozoclown.com ErrorLog logs/bozo_error_log ErrorDocument 401 errors/401.html ErrorDocument 404 errors/404.html ErrorDocument 403 errors/403.html </VirtualHost> 

The custom error files 401.html, 403.html and so on are in the errors subdirectory, which is off the document root. If I point a browser at www.bozoclown.com/errors/403.html, the 403.html files comes up (so it, and the other error files, are there, and accessible). But, when I intentionally generate a 403 error accessing the virtual site, I'm not being sent to the custom 403 page. Instead, I'm getting the following error:

You don't have permission to access / on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request. 

So, I try adding the following in the virtual host declaration:

<Directory "/home/www/htdocs/virtual/bozo/errors"> Order allow,deny Allow from all </Directory> 

But that doesn't work.

Suggestions? Pointers to the obvious correction I need to make?

Thanks in advance.

1 Answer 1

0

You gonna need to modify your configuration file a little, you need an Alias directive to map the /errors URL path, update the ErrorDocument to the URL path instead of the file path.

Here is the final file, after restarting the Apache server it should work

<VirtualHost <ip.address.here>> ServerAdmin [email protected] DocumentRoot /home/www/htdocs/virtual/bozo ServerName www.bozoclown.com ErrorLog logs/bozo_error_log Alias /errors "/home/www/htdocs/virtual/bozo/errors" <Directory "/home/www/htdocs/virtual/bozo/errors"> Options -Indexes Order allow,deny Allow from all </Directory> ErrorDocument 401 /errors/401.html ErrorDocument 404 /errors/404.html ErrorDocument 403 /errors/403.html </VirtualHost> 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.