Using Windows Hosts file to prepare for website launch

AID: 4605
  • Status: Published

1550 points

  • Byblueghozt
  • TypeTips/Tricks
  • Posted on2011-03-01 at 02:10:07
As a web developer you often don't have access to internal DNS servers to test websites that you are working on.
As an alternative we can use the Windows Host File.  This allows me to use internet Explorer to view the actual URL without making it live on the internet.
This allows me to test and configure the site using the correct base URL as it awaits domain propagation.

To make the required changes to your hosts file the following steps should be completed:

Step 1 - On a Windows machine click the Start button and in the Accessories folder find Notepad – but don’t left click it open, instead right click for a menu that includes the option to “Run as administrator” – select this and Notepad will open.
The reason we do this is that on windows Vista and Windows 7 computers the host file cannot be edited using regular permissions so Run As Administrator is required.

Step 2 - Use the File menu in Notepad to select Open… then browse to %systemroot%\System32\drivers\etc – you will probably see a blank folder and this is because by default Notepad is set to look for files of type .txt – so using the drop down there select All Files (*.*) which will reveal the files without extensions, you should now see a file called “hosts” – open this file

At the bottom of the file insert your hosts directive which has the format of IP-address space domain-name, for example:

23.23.253.12 domain.com

(do *not* use www. in your domain name!) once you have inserted this line click Save and close Notepad.

Now when you enter this domain name, without the www. part, in any of your browsers it will direct your request to the IP address you specified. To view the actual website the domain is pointing to before you switch it to the new server just use the www. in front of the domain e.g. www.domain.com – this will bypass your hosts directive.
Asked On
2011-03-01 at 02:10:07ID4605
Tags

hosts file

,

staging

,

launch strategy

Topic

Miscellaneous Web Development

Views
1029

Comments

Author Comment

by: blueghozt on 2011-03-03 at 15:54:37ID: 24198

Hi - this is my blog - I am Alistair Macdonald - I thought this would be a useful article for here.

What do you need from me to prove that it's my blog?

Thanks,

Ali
(ali@nubz.com)

Author Comment

by: blueghozt on 2011-03-03 at 16:09:11ID: 24199

I have just updated my EE profile with my real name and site URL (http://nubz.com), just realised you would find it hard to make the connection (although my registered gmail address does use my real name alistair.k.macdonald@gmail.com)  - feel free to use the contact form on that site to get a confirmed response or email me at ali@nubz.com - alternatively I could update the blog article in question on my site in any way you wish!

Thanks, I do understand your need to do this!

Ali

Author Comment

by: blueghozt on 2011-03-03 at 16:21:47ID: 24200

I have just added a small rider to the about page on my blog to confirm that I am on EE as blueghozt - http://blog.nubz.com/about/ - hope this clears it up!

Author Comment

by: blueghozt on 2011-03-04 at 01:12:28ID: 24204

thanks for your comments - the reason I propose the opening through notepad is that you can launch notepad with administrator priviliges and then browse to the hosts file - when I paste in the path to windows explorer I can find the file and open it but cannot save it as I do not have administrator priviliges, I thought this was an important point. This way works for me and my many clients with varying technical abilities, we are able to view the site at domain.com or test.domain.com within seconds of doing this.

I will await the PE verdict!

Author Comment

by: blueghozt on 2011-03-04 at 01:36:44ID: 24208

fine with that :)

Add your Comment

Please Sign up or Log in to comment on this article.

Join Experts Exchange Today

Gain Access to all our Tech Resources

Get personalized answers

Ask unlimited questions

Access Proven Solutions

Search 3.2 million solutions

Read In-Depth How-To Guides

1000+ articles, demos, & tips

Watch Step by Step Tutorials

Learn direct from top tech pros

And Much More!

Your complete tech resource

See Plans and Pricing

30-day free trial. Register in 60 seconds.

Loading Advertisement...

Top Misc Web Dev Experts

  1. COBOLdinosaur

    144,341

    Master

    0 points yesterday

    Profile
    Rank: Genius
  2. Ray_Paseur

    142,428

    Master

    3,800 points yesterday

    Profile
    Rank: Savant
  3. jason1178

    102,330

    Master

    0 points yesterday

    Profile
    Rank: Genius
  4. DaveBaldwin

    76,853

    Master

    2,200 points yesterday

    Profile
    Rank: Genius
  5. ve3ofa

    50,168

    Master

    0 points yesterday

    Profile
    Rank: Genius
  6. nap0leon

    45,060

    0 points yesterday

    Profile
    Rank: Sage
  7. mplungjan

    45,026

    0 points yesterday

    Profile
    Rank: Savant
  8. leakim971

    33,300

    0 points yesterday

    Profile
    Rank: Genius
  9. ChrisStanyon

    28,132

    0 points yesterday

    Profile
    Rank: Sage
  10. tommyBoy

    26,968

    0 points yesterday

    Profile
    Rank: Genius
  11. Tiggerito

    26,204

    0 points yesterday

    Profile
    Rank: Sage
  12. kozaiwaniec

    19,800

    0 points yesterday

    Profile
    Rank: Guru
  13. shalomc

    19,268

    0 points yesterday

    Profile
    Rank: Genius
  14. LZ1

    17,720

    0 points yesterday

    Profile
    Rank: Genius
  15. webmatrixpune

    17,668

    0 points yesterday

    Profile
    Rank: Guru
  16. padas

    16,992

    2,000 points yesterday

    Profile
    Rank: Wizard
  17. sammySeltzer

    16,568

    0 points yesterday

    Profile
    Rank: Genius
  18. Gertone

    16,100

    0 points yesterday

    Profile
    Rank: Genius
  19. hielo

    15,700

    0 points yesterday

    Profile
    Rank: Savant
  20. singleton

    14,400

    0 points yesterday

    Profile
    Rank: Guru
  21. kaufmed

    14,376

    0 points yesterday

    Profile
    Rank: Genius
  22. paulmacd

    13,998

    0 points yesterday

    Profile
    Rank: Genius
  23. StingRaY

    13,668

    0 points yesterday

    Profile
    Rank: Wizard
  24. ahoffmann

    13,608

    0 points yesterday

    Profile
    Rank: Genius
  25. sudaraka

    13,000

    0 points yesterday

    Profile
    Rank: Sage

Hall Of Fame