Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I just want to setup a local server on my pc. I have WAMP installed. Now, for test, I wrote in hosts file, in location C:\WINDOWS\system32\drivers\etc. But, when I am loading, it's not loading anything. Actually, I want to make my folder C:/wamp/www/test to load like, www.test.loc

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You want to set up the hosts file like this: (Note: wildcards are not supported)

#the hash marks make the system ignore the text here, you can make comments

You will not be able to visit anymore, so I recommend something like this:

#dev server #this does not have to exist in real life

#another host test.loc www.test.loc

These are only accessible from your local system. To be public, you have to purchase the domain name.

I'm not quite sure what you did here: "I wrote in hosts file" but you MUST specify an IP address on the left, and a host name on the right. Windows Hosts File does not understand canonical names, being on the left and on the right


Add this to a .htaccess for those redirects.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*).test.loc
RewriteRule ^(.*)$ http://test.loc/%1 [L]
RewriteBase /
share|improve this answer
thanks for your answer. I want to internally use localhost/test/* when i enter urls www.test.loc/*. Can it be done using something like If it can't be done from hosts file, then what else method will be better for doing this on my local pc. – Thompson May 12 '12 at 19:47
See my edited post above, it doesn't align correctly here. – ionFish May 12 '12 at 20:19
Thanks again ionFish. Doing all this takes me to the localhost, and not to the localhost/test folder – Thompson May 13 '12 at 4:34
Well, what that was supposed to do is map to (requiring you to have a folder there). I am not sure what to tell you now. That's what we use for one of our sites. – ionFish May 13 '12 at 5:56

You're looking in the wrong place. I'd recommend reading up on some stuff:

Once all the concepts are clear in your mind you should find it simple to do what you want. The key points are.

  • Your local webserver almost certainly listening on
  • You do not need a DNS / host entry to make use of it.
  • The part of the URL after the IP address can be configured via your webserver software.
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.