I'm not sure if this is the right section...if not, please move.
I'm trying to block internet access to certain sites on my home computer. How can I edit the HOSTS file to do this? I have already told the hosts file to redirect to 127.0.0.1, but the catch is that I want the blocked access to deliver a message of my choosing.
Is there a way to direct these blocked sites to a page on my computer or website?
Either use an on-page script, or use Apache mod_rewrite or ISAPI Rewrite on IIS to rewrite such unwelcome requests to a file (e.g. page or script) of your choosing.
Sorry, I think I didn't explain myself very well.
I'm not running Apache.
Let's say I don't want anyone in my house visiting www.yahoo.com. So, I add the appropriate data to the hosts file so that www.yahoo.com gets patched to 127.0.0.1.
Now, let's say someone tried to open Firefox and visit www.yahoo.com. Instead of just giving a server can't be found error, I'd like it to display a webpage I've created.
I assume that I could do this with pretty decent ease in Apache, but I don't need Apache on my home pc...so I'd like to keep it simpler, if possible.
If you have a website, upload the page you want to show there, and use the hosts file to point traffic for blocked domains to that location.
This would only work for the machines you edited the hosts file. Some routers have this feature built in, consult your router manual.
I've attempted redirecting to a host name (http://www.mysite.com), but it doesn't work. Is there a special format?
if you're redirecting to 127.0.0.1 all you really need to do is install apache, which is easy, and then put an index.html file in the htdocs folder containing whatever you want to say.
you'll have to remember to set it up so apache starts automatically everytime a user logs-on.
but maybe it would be better to redirect to a different page on localhost instead. because if the browser's homepage is set to localhost, then they'll see the page everytime they start the browser up.
Sorry, maybe I'm hijacking your topic inveniO. But I have similar problem with this. Before that, I'm still running on Virtual machine which is VirtualBox. Lets say I have 3 servers (server A.B and C) and 1 client. Server A is the primary server to run the website (ex. foo.com) and the IP Address is 192.168.0.125. So when the client type server's A IP Address, it will see the site's page. My question is, when the server A down, I want to change to server B which has the same name like server A. So it means the connection to server A has been blocked and change it to server B or C. How to do that? I'm running LAMP on Ubuntu host and guest.
Thanks in advanced.
inveni0: you'll cannot achieve this with HOSTS--it works on TCP/IP level, whereas you need HTTP level. Most SOHO hardware routers have this feature (and give you home computer extra protection from outside attacks), or you need to look for some firewall program to install on your home computer.
re3bo0t: you'll need some sort of load-balancing technique: either an appliance (look for BigIP, Barracuda Load Balancer etc), or you can play with Apache's mod_proxy & mod_status.