I'm trying to use the same 404 ErrorDocument for a domain and all its subdomains, The subdomains all have their own directory in the /var/www/ path
the Apache ErrorDocument directive expects a relative path (relative to the current directory) but I want it to go to /var/www/ErrorPages/404.html from all directories/subdomains
There is a similar question here asked in 2010 but it does not eleborate on the solution, I have tried Alias and couldn't get it to do what I want.
Example 1:
file http://example.com/doesnotexist.txt
requested
-> show /var/www/mervin/ErrorDocuments/404.html
as response
Example 2:
file http://subdomain.example.com/otherimaginaryfile.txt
requested
-> show /var/www/ErrorPages/404.html
as response
Virtualhost:
<VirtualHost *:80>
ServerName www.mervinkoops.net
ServerAlias mervinkoops.net *.mervinkoops.net spirecoder.com www.spirecoder.com *.spirecoder.com
DocumentRoot /var/www/mervin
ErrorDocument 404 /ErrorDocuments/404.html
Redirect 404 /favicon.ico
RewriteEngine On
RewriteCond %{HTTP_HOST} public\.mervinkoops\.net [NC]
RewriteRule ^(.*)$ /public/$1 [L]
RewriteCond %{HTTP_HOST} pma\.mervinkoops\.net [NC]
RewriteRule ^(.*)$ /PHPMyAdmin/$1 [L]
RewriteCond %{HTTP_HOST} www\.mervinkoops\.net [NC]
RewriteRule ^(.*)$ /website/$1 [L]
RewriteCond %{HTTP_HOST} mervinkoops\.net [NC]
RewriteRule ^(.*)$ /website/$1 [L]
RewriteCond %{HTTP_HOST} www\.spirecoder\.com [NC]
RewriteRule ^(.*)$ /website/$1 [L]
RewriteCond %{HTTP_HOST} spirecoder\.com [NC]
RewriteRule ^(.*)$ /website/$1 [L]
<Directory /var/www/mervin/>
allow from all
Options -Indexes
RewriteBase /
</Directory>
</VirtualHost>
How would I go about doing this?
Other info: Apache2.2, MOD_ALIAS working, MOD_REWRITE working, Symbolic Links enabled