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.