Take the 2-minute tour ×
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 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

share|improve this question

2 Answers 2

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

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

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

#another host
127.0.0.1 test.loc
127.0.0.1 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

EDIT:

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 127.0.0.1/test/ 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 http://127.0.0.1:80/
  • You do not need a DNS / host entry to make use of it.
  • The part of the URL after the IP address http://127.0.0.1:80/eg-this-part can be configured via your webserver software.
share|improve this answer

Your Answer

 
discard

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.