?
Solved

server wide ErrorDocument with virtual hosts

Posted on 2004-10-02
4
Medium Priority
?
435 Views
Last Modified: 2013-11-18
hey there,

In my apache config file I have this as the default directory:

<Directory "d:/www">
    Options FollowSymLinks +ExecCGI
    AllowOverride None
  AddHandler cgi-script .pl
  ScriptInterpreterSource registry
    Order deny,allow
    Allow from all

  ErrorDocument 404 /custom/cust_404b.html

</Directory>        


then I have a couple of virtual hosts defined like this:

<VirtualHost 123.123.123.123:80>
  ServerName demo.example.com
  DocumentRoot d:/www/demo
</VirtualHost>  

The problem is that the way I have it set up, I have to have a separate "/custom/cust_404b.html" directory and file in every virtual host directory since the URL path to the error document is relative.   How can I have a server wide custom error document such that a 404 for any domain/page combination hosted by my server returns the same error document?  

thanks!

-andrew


0
Comment
Question by:mcdunna77
2 Comments
 
LVL 15

Accepted Solution

by:
periwinkle earned 252 total points
ID: 12208891
There's a couple of solutions that come to mind.

You can have a rule like:

ErrorDocument 404 http://www.yourdomain.com/custom/cust_404b.html

however, that has the disadvantage of shifting domains to yourdomain.com, instead of staying with the domain of your virtualhosts (like demo.example.com).

You could add an alias, like:

Alias /custom/cust_404b.html d:/www/custom/cust_404b.html

... that would probably do the trick!  I'm not certain if you could just put that in the 'default' config, or if you'd have to put that in each of the subsequent virtual hosts.
0
 
LVL 4

Assisted Solution

by:TomDavidson
TomDavidson earned 248 total points
ID: 12228120
I've found that this works best with an alias for each virtualhost for many shared resources including all the ErrorDocs.

I'm sure I had the alias declared in the global section of the configuration.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is an update and follow-up of my previous article:   Storage 101: common concepts in the IT enterprise storage This time, I expand on more frequently used storage concepts.
In this article we will learn how to backup a VMware farm using Nakivo Backup & Replication. In this tutorial we will install the software on a Windows 2012 R2 Server.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question