Add 404 Page for all nonexistent Subdomains


#1

Hello! I have been trying to add a 404 Page for all non-existent Subdomains on - similar to how 000webhost does it with
http://nonexistantsubdomain.000webhostapp.com

Any help? I’ve been looking for this for hours online :expressionless:


#2

Please explain further.
Do you mean you have a domain, and you wamt all unexisting subdomains redirect to that?


#3

Hi you can achieve it by creating a custom file let’s take for example 404.html , it is your 404 error page when visitors will visit any non existent url on your domain and then create a file called .htccess and add this piece of code into it
ErrorDocument 404 /404.html


#4

Yes, i would like all on existing subdomains to redirect to that :grinning:


#5

But that only seems to work for pages on my site that dont exist. I would like a custom 404 page for all subdomains that dont exist - similar to http://notasubdomain.000webhostapp.com/


#6

That would work if you had a VPS, you would redirect everything the VPS does not know to that page.

Shared hosting does not allow that on the other hand, if you do so, all subdomains would redirect to the 000webhost 404 page


#7

Another alternative would be to use cloudflare’s page rules.

Example


#8

I got it to work with Cloudflare, but it just shows the 000webhost error page rather than my own. How do I change that?


#9

You can’t :slight_smile:
A VPS is the only way to do so, as you can tell the server to redirect to your own 404 if the subdomain does not exist


#10

ok :grinning: thanks for your help.

Could you please explain what a VPS is?


#11

#12

Thanks :+1::grinning:


#13

So did we solve your problem?


#14

yes, i think ill just leave it with the 000webhost error page for now with cloudflare, but im looking into vps now :+1:


#15

Thanks for all of the quick responses, it helped a lot :grinning:


#16

Anytime :slight_smile:


#17