<

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Using Windows Hosts file to prepare for website launch

Published on
8,530 Points
2,530 Views
Last Modified:
Approved
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.
0
Comment
Author:blueghozt
  • 5
5 Comments
LVL 6

Author Comment

by:blueghozt
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)
0
LVL 6

Author Comment

by:blueghozt
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
0
LVL 6

Author Comment

by:blueghozt
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!
0
LVL 6

Author Comment

by:blueghozt
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!
0
LVL 6

Author Comment

by:blueghozt
fine with that :)
0

Featured Post

Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Join & Write a Comment

This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will learn how to dynamically set the form action using jQuery.

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month