Jump to content

vhost error docs


the_oliver

Recommended Posts

Im trying to have individual error pages for each of my vhosts.  The part thats proving difficault is having the error pages outside the Document root.  Eg DocumentRoot /var/www/domain.com/httpdocs  and errors in /var/www/domain.com/error.

 

The vhost code im using is:

 

<VirtualHost *:80>
  ServerAdmin webmaster@domain.com
  DocumentRoot /var/www/domain.com/httpdocs
  ServerName www.domain.com
  CustomLog logs/domain_log combined

       <IfDefine ERRORDOCS>
               Alias /error/ "/var/www/doman.net/error/"
               <Directory "/var/www/html/domain.com/error/">
                       AllowOverride None
                       Options IncludesNoExec
                       AddOutputFilter Includes html
                       AddHandler type-map var
                       Order allow,deny
                       Allow from all
               </Directory>
       </IfDefine ERRORDOCS>

        ErrorDocument 404 /404.html

 

 

However when i tried to restart the service if get the following error:

Starting httpd: Syntax error on line 1112 of /etc/httpd/conf/httpd.conf:

Expected </IfDefine> but saw </IfDefin>

 

Line 1112 is the one above starting "<IfDefine ERRORDOCS>".  Can anyone offer me some advice?

 

- Thanks!

Link to comment
Share on other sites

I thought of that, but apparently it reads from the DocumentRoot, rather then the /var. So it told me it couldnt fint the error page!  I also tried ../error but then when it needed an error page it just printed ../error to the browser!

So it would try to reed form /var/www/doman.com/httpdocs/var/www/...ect..

 

Thanks!

Link to comment
Share on other sites

Ah - ok. I read your initial post too quickly...again.

 

Right - so you want your ErrorDocument outside of your DocumentRoot.

Well this should work on its own so. Add these lines into the vhost:

 

Alias /error/ "/var/www/doman.net/error/"

ErrorDocument 404 /error/404.html

 

I have tested, and that works fine for me. Make sure that the file "/var/www/doman.net/error/404.html" has read permissions to be read by the webserver, i.e. chmod 644.

 

-steve

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.