views:

46

answers:

2

I've got a number of subdomains on one of my sites. When someone goes to a subdomain that doesn't exist, I want to redirect to a 404 page on my main domain.

noexist.example.com --> example.com/404.php?subdomain=noexist (or without the query string if HTTP_REFERRER can give me that info)

I'm running LAMP on a VPS with cPanel installed. I can edit the DNS Zone file for the domain via WHM.

A: 

There are a ton of tutorials on how to create a custom 404 page, no need to redirect as apache should take care of this for you.

Phill Pafford
These links are for setting up a 404 page on a domain that exists. In my scenario, a user might go to sub.example.com where the subdomain "sub" has not been created and does not exist. Currently when a browser hits a non-existent subdomain, it simply tells you that it can't resolve the server. I want to go to an error page instead.
Jazzerus