Mobile app version of vmapp.org
Login or Join
Sims2060225

: How do you make a 404 page for every non-existant subdomain? I have a site http://example.com how do you make a 404 page for subdomains that do not exist? e.g if I was to try and visit

@Sims2060225

Posted in: #Subdomain

I have a site example.com how do you make a 404 page for subdomains that do not exist?

e.g if I was to try and visit a-sub-domain-that-does-not-exist.stackexchange.com I get a 404 page.

The default behavior for subdomains is that they don't resolve. I would instead like to create a user-friendly "not found" page for them.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Sims2060225

1 Comments

Sorted by latest first Latest Oldest Best

 

@Si4351233

Based on your comments I am making the assumption that you will be defining a catch all dns record for your domain, eg: *.example.com IN A 1.1.1.1 so that all sub domains of example.com that are not specifically mentioned will be routed to the web server. In this instance this would be handled by your server code. All you would do is detect the domain name, if the requested sub domain does not exist then you would send a HTTP 404 header and output a standard HTML page stating that the site requested does not exist. This would both present a friendly page for the user to see the site doesnt exist as well as sending the correct headers so that Google and other automated systems detect that the site doesn't exist and don't try indexing your error page.

As a side note you only need to do this if you are using wildcard DNS entries. If you will be defining each and every DNS entry manually then there is no need to do this part as if a DNS record is requested that doesn't exist the browser automatically returns an error message saying that the requested domain name doesn't exist.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme