Using Separate Host or Domain Names for Website Development on Windows with IIS or Apache Using Hosts File

Whether you run IIS or Apache you can run local sites similar to 'localhost'.

When you type localhost in your browser's address bar and hit enter, the address always translates to the loopback IP address 127.0.0.1 in IPv4, or ::1 in IPv6.

You can easily create similar names which will always translate to loopback IP address 127.0.0.1 or point to any specific IP address of your choice.

Here is what you have to do:

1. Press Windows key + R, the Run... dialog box will appear. - If your keyboard lacks the Windows key, you may click Windows Start button and then click on Run... option in the Start menu.

2. Type drivers and hit enter, the Windows explorer will appear.

3. Now browse to drivers/etc/

4. Open the host file with Notepad application.

You'll see at least on entry inside your host file. Almost all host file contain the following entry:

127.0.0.1 localhost

To add another entry, change your host file in this way:
127.0.0.1 localhost
127.0.0.1 local.com

Save your hosts file.

Try loading local.com from your browser, do NOT add www. You will see that you are hiting Apache or IIS on your own computer.

Now, reopen host file and add one more entry:

127.0.0.1 localhost
127.0.0.1 local.com

127.0.0.1 www.local.com

Save the file and try to load the new URL www.local.com from your browser and you continue to hit your local web server.

Another shot:

127.0.0.1 localhost
127.0.0.1 local.com
127.0.0.1 www.local.com

127.0.0.1 www.yahoo.com

Save the file and now you can NEVER access the real Yahoo but will see the localhost site from your web server.

Another important aspect:

127.0.0.1 localhost
127.0.0.1 local.com
127.0.0.1 www.local.com

127.0.0.1 www.yahoo.com
192.168.0.5 www.ebay.com

Save your hosts file. Now whenever you will type www.ebay.com on your browser you will be taken to the webserver running on your network computer that has the given IP address of 192.168.0.5.

Bingo, you're ready for the next tutorial on configuring Apache and IIS to serve or show different content when different domain names are passed.

Don't jump into conclusions and remeber that: 1. This will not change the settings of your websites users or anything outside your computer. 2. Just because you added ebay.com to your host file doesn't make you owner of that domain name. 3. Nobody else can visit your site by typing local.com and until they specifically update their hosts file 4. Don't try to hack into someone else's computer using this concept since you will be caught just too easily and it will be foolish to spend dozens of years in jail for such a simple hack. If you want to serve jail time then it better be some serious hack.

Comments

  1. It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait to read. I am impressed with your work and skill. Thanks. website designer Miami

    ReplyDelete
  2. Thank you for putting all these strategies into a very readable place. It shows your ability and great skills. keep sharing such article in future. Custom Website Development Services

    ReplyDelete
  3. It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait to read. I am impressed with your work and skill. Thanks. Read more info about website development san antonio

    ReplyDelete
  4. You composed this post amazing about this topic. I got data from your article, it is precious for me and furthermore for other people. Continue sharing this sort of information. Website Development Tampa

    ReplyDelete
  5. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. Read more info about Affordable Graphic Designer Singapore

    ReplyDelete
  6. This article provided me with a wealth of information about web design company sydney. The article is both educational and helpful. Thank you for providing this information. Keep up the good work.

    ReplyDelete
  7. You have posted an excellent article. It is all about the Website Development. It is very informative. Website Design And Development Services Australia.Keep sharing.

    ReplyDelete
  8. Excellent post. I really enjoy reading and also appreciate your work. This concept is a good way to enhance knowledge. Keep sharing this kind of articles, Thank you. Web Design Development Company

    ReplyDelete
  9. You have worked nicely with your insights that makes our work easy. The information you have provided is really factual and significant for us. Keep sharing these types of article, Thank you. Website Development Company in India

    ReplyDelete
  10. I liked your work and the way in which you have shared this article here about. website online backup service in canadaIt is a beneficial and helpful article for us. Thanks for sharing an article like this.

    ReplyDelete

Post a Comment

Be relevant. Spammers will be banned.

Popular posts from this blog

Installing ColdFusion on IIS 7 + Configure IIS for ColdFusion in Windows Vista and Windows Server 2008

ColdFusion Manual Configuration & Issues with TCP ports 51011, 51010 and 51800 on IIS and Apache

Configuring Apache Tiles to Avoid Caching During Development