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


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 www.google.com google.com

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

#dev server mohan.com #this does not have to exist in real life www.mohan.com

#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 www.google.com www.google.temp 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 www.google.com and on the right www.google.temp


Add this to a .htaccess for those redirects.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*).test.loc
RewriteRule ^(.*)$ http://test.loc/%1 [L]
RewriteBase /
  • 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 anything.domain.com to domain.com/anything (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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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