The keyboard I use at work has some keys on it that are a bit tough to press. Being someone who types all day long as part of my job, this is somewhat annoying. Only slightly more annoying is what happens when I attempt to type in gmail.com, but accidentally enter gmail.cm. You can visit gmail.cm and see for yourself, but I suggest you take my word for it when I say the site resizes your browser.
I’m pretty particular about my browser window, its size, and its placement, so when a site resizes it, I get irritated. To make matters worse, I visit gmail.com several times a day and about a third of the time I make the typo, which means my browser gets resized daily.
I’ve been putting up with this for a while, but after it happened again this morning, I decided I had put up with long enough. I blocked access to gmail.cm altogether, and in case you ever need to know how to block access to websites in OS X, I’ll tell you how I did it (like everyone else, I assume no responsibility if you break your computer).
To accomplish this, you’re going to need root access to the machine (which you have if you know the administrator password). Open the application called Terminal (it’s in the Utilities folder inside your Applications folder). You’re going to edit your ‘hosts’ file, and it’s always a good idea to back stuff up before you goof around with it. To do that, type in:
sudo /bin/cp /etc/hosts /etc/hosts.backup
Press ‘enter’ and type in your password. Now you’re ready to edit the file. Type in:
sudo /usr/bin/pico /etc/hosts
When you press ‘enter,’ your ‘hosts’ file will open in a text editing program called pico. Use the arrow keys to move the caret to the end of the last line and hit ‘enter’ a couple of times to get to a new, blank line. Then type in:
Obviously, if you want to block a site other than gmail.cm, you would type that in instead. Once you’re finished adding sites you want to block, press ‘control’ and ‘x’ at the same time. Pico will ask if you want to save your changes, so press ‘y’ and then ‘enter.’
To test your work, clear your browser’s cache and try to visit gmail.cm (or whatever you typed in). Your browser should say that it can’t find the site. So what magic did you do to accomplish this? You told your computer to look for gmail.cm and www.gmail.cm at the IP address 127.0.0.1, which is the localhost IP address. In plain English, that means it’s looking for gmail.cm on your own computer (127.0.0.1 always means “this computer”). Since gmail.cm obviously isn’t hosted on your machine, it doesn’t work (if your computer is set up to serve web pages, you’ll likely see that instead of an error message).
Pro Tip: Instead of using 127.0.0.1 and having the site fail altogether, use the IP address of an actual website and have OS X automatically forward you to a useful site. Unfortunately, every IP address I can find for gmail.com takes me to google.com instead.0 People like this. Be the first!