Saturday, July 04, 2009Login    
Will Strohl - The Mighty Blog - RSS Feed

 Most Popular Entries 
 Blog Tag Cloud 
 Blog Roll 
 Search Blog 
 Blog Archive 

 


 The Mighty Blog 
Feb13

Written by:Will Strohl
2/13/2008 

Sometimes when you are programming or debugging a site, or even when you are using certain 2rd party controls, you cannot effectively do so unless viewing the site using an actual URL. "Localhost" might be causing grief in any number of ways. Here is how to mask or fake a domain name...

First of all, you will need to be running Windows and have your system configured to have and run IIS.  After that, the rest is cake...  The first thing we need to do is determine what URL you want to use.  In our example here, I will choose to use "www.anywhere.com"

Go into IIS, and enter the properties for your site.  Unless you are running a server instance of Windows, you will only have a single site.  Right click on it to get to the site properties.

In the "Web Site" tab, click the "Advanced" button.

Click the "Add" button to add an identity to the site.  Enter the port as number 80, and then enter the URL into the "Host Header Name" field.  (Please note that you might want to repeat this step if you intend on not using the "www." in the URL.)

Click OK to exit out of all of the dialogs and to save your changes.

Go into your system32 directory.  This is either found in the WINDOWS or WINNT directory on your hard drive.  Either way, continue to the following directory.

C:\WINDOWS\system32\drivers\etc\
C:\WINNT\system32\drivers\etc\

Within this directory, there is a file named "hosts".  Make a copy of this file to use as a backup in case you mess something up somehow.

Now, open up the hosts file using NotePad.  Add the following lines of text to the file and save your changes.

127.0.0.1 anywhere.com  # localhost alias
127.0.0.1 www.anywhere.com # localhost alias

That's it!  Your site should already be responding to requests made to the anywhere.com domain.  On small occasions, you may have to restart IIS, or clear your local DNS cache.  Otherwise, your site is ready to use the domain name locally. 

Tags:

5 comment(s) so far...

Thank you so much.
Worked like a charm

By Evan Cutler on   10/2/2008

My pleasure!

By wills on   10/2/2008

Have you find a workaroud to use with the VS 2008 built-in test server ? It is on port 1884 (normally) and capturing this port in IIs does any good because this test server is not related to the default site visible in IIS

By Philippe Forget on   11/7/2008

Ok the preceding one was a newbie question... You cannot modify such parameters for the built-in VS2008 test server. What you can do is to setup your project to use IIS instead of this test environment. To do so, you must go in your project properties page (Project-> Properties of [project name]). Then select the Web tab. In the server section of this form you can select Use IIS web server.

By Philippe Forget on   11/7/2008

You answered your question before I could. Thanks for the help! ;)

By wills on   11/7/2008

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment   Cancel 
Add to Technorati Favorites
Tweet about my blog
© Copyright 2004-2009 by Will Strohl. All rights reserved.