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 [email protected]
  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
https://forums.phpfreaks.com/topic/51088-vhost-error-docs/
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
https://forums.phpfreaks.com/topic/51088-vhost-error-docs/#findComment-251906
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
https://forums.phpfreaks.com/topic/51088-vhost-error-docs/#findComment-253423
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.