Welcome to WebmasterWorld Guest from 54.198.87.238

Forum Moderators: phranque

Message Too Old, No Replies

Forwarding 127.0.0.1?

     
9:03 pm on Nov 1, 2009 (gmt 0)

5+ Year Member



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?

9:34 pm on Nov 1, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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.

Jim

9:58 pm on Nov 1, 2009 (gmt 0)

5+ Year Member



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.

10:08 pm on Nov 1, 2009 (gmt 0)

WebmasterWorld Administrator mack is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.

Mack.

3:14 pm on Nov 2, 2009 (gmt 0)

5+ Year Member



I've attempted redirecting to a host name (http://www.mysite.com), but it doesn't work. Is there a special format?
3:25 pm on Nov 2, 2009 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



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.

2:45 pm on Nov 18, 2009 (gmt 0)

5+ Year Member



Hi,

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.

2:24 pm on Jan 5, 2010 (gmt 0)

10+ Year Member



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month