user3602420
user3602420

Reputation: 127

a custom 404 page for all my subdomains.

I want all my subdomains to have the same custom 404 error page. In the htaccess file of the htdocs folder I have tried the following solutions:

ErrorDocument 404 /www/errordocument/404.php
ErrorDocument 404 www/errordocument/404.php
ErrorDocument 404 http://www.mydomain.com/errordocument/404.php

None of them seems to work except for the last one. Only this one gives a 302 redirect and changes the url in the address bar. Which I don't want. I can make a 404 file + htaccess file in all the subdomains only than if someone goes to a non existing subdomain they dont get the custom 404.

how can this be done?

note: server has Apache 2.0 handler

Upvotes: 1

Views: 2593

Answers (1)

anubhava
anubhava

Reputation: 786329

You can keep /errordocument/ folder directly under DocumentRoot of parent domain and then have this directive in the .htaccess of parent domain:

ErrorDocument 404 /errordocument/404.php

After this under all the sub domain's DocumentRoot folder (which will be a sub directory under parent's DocumentRoot) create symbolic links like this:

cd sub1; ln -s ../errordocument; cd -
cd sub2; ln -s ../errordocument; cd -

Upvotes: 2

Related Questions