I must redirect from not existing subdomains to error page in order to primary domain. I've got a large amount of subdomains and they're produced and erased dynamically so i don't control the procedure and don't understand what exactly subdomains are produced or erased at this time.

If a person user removes his subdomain i must redirect site visitors to primary domain or simply show error page with custom message, exactly the same like it's produced by blogspot.com:

Allows say should you type any not existing subdomain it teaches you error page that states that subdomain page doesn't exist, random example (you might type any not existing subdomain title and find out result):

http://NotExistingSubdomain.blogspot.com/

Any help appreciated. Thanks, Tim