0

Hosts file is blocking access to some websites. How do i put custom HTML instead of default message "This site can’t be reached"?

  • If you are just forwarding these websites to localhost (127.0.0.1), you can use some software like apache2 to put an HTML in localhost. – pixelomer Mar 13 '18 at 14:49
2

One has nothing to do with the other.

A hosts file is just a "directory" of host names and their IP addresses. It's not limited to websites. You can think of it as a "flat file DNS lookup."

# Sample hosts file
#

123.456.789.001      foo.bar

With this address, you can...

  • Go to a website - http://foo.bar
  • SMB share : smb://foo.bar
  • SSH connection: ssh user@foo.bar
  • Copy files securely from one host to another - scp stuff.ext user@foo.bar:/path/stuff
  • and much more

In order for your browser to display a web page, it must be "served" that page. Since, by default, your clients aren't running a web server, there's nothing to serve.

I'm assuming that you want to display this "web page" when someone goes to a site you "blocked" by using a custom hosts file.

You need to do this at the (your) network level where the DNS lookup redirects (or firewall intercepts/redirects) to a server hosting your error page.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .