httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dragon <>
Subject Re: [users@httpd] Apache Conf
Date Fri, 30 Mar 2007 16:09:22 GMT
Dragon wrote:
>Kyle Vorster wrote:
>>Hi Guys,
>>I am trying to tweak a apache server installed with cPanel.
>>What I am trying to do is set server-wide 'custom' error pages, but 
>>when a user uploads his own set of 'custom' error pages it should 
>>over-right the server-wide pages and display the users pages.
>>so looking at something like this
>>if (is_file(/home/$user/public_html/404.shtml))
>>  display /home/$user/public_html/404.shtml;
>>} else {
>>  display /usr/local/apache/htaccess/404.shtml;
>>Any one know how this could be done, or direct me to the right documents.
---------------- End original message. ---------------------

Now I am no Apache guru by any means so I may be a bit off-base here...
Settings redefined later in teh configuration override those set 
earlier. You would define the default server pages first (which is 
probably already done in your httpd.conf file). Then you would see if 
the file you are looking for exists in each user directory. Using the 
DirectoryMatch directive and a regular expression to match each one 
keeps you from having to configure this for every user.

If you wanted to get really sophisticated about it, you could make 
the regular expression a lot more complex to match a variety of 
potential patterns and use a FilesMatch directive with a regular 
expression to allow alternative file extensions or filenames for the 
error documents too.

Just doing a simple version without all the extra stuff, I think you 
could probably do it with something like this (if somebody else has a 
better idea, feel free to hack my stuff apart):

# Add an ErrorDocument directive for each error you wish to support
# Use default to get Apache's default error page or specify a server-wide
# error document for each error type

ErrorDocument 404 default
ErrorDocument 500 default

# Now override the defined error page for each user directory if
# there is a file defined with a matching name. You will have to
# enforce the file naming convention for this to work and the error
# documents must live in the root of each of the user directories

<DirectoryMatch "/home/(.+)/public_html">
         # Add a <Files> section for each error type
         <Files "404.shtml">
                 ErrorDocument 404 /404.shtml
         <Files "500.shtml">
                 ErrorDocument 500 /500.shtml


  Venimus, Saltavimus, Bibimus (et naribus canium capti sumus)

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message