Mobile app version of vmapp.org
Login or Join
Gail5422790

: Working with Host file in Windows XP? 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

@Gail5422790

Posted in: #WebHosting

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

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Gail5422790

2 Comments

Sorted by latest first Latest Oldest Best

 

@Gonzalez347

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

en.wikipedia.org/wiki/Domain_Name_System en.wikipedia.org/wiki/IP_address http://en.wikipedia.org/wiki/Webserver


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 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 127.0.0.1:80/eg-this-part can be configured via your webserver software.

10% popularity Vote Up Vote Down


 

@Ravi8258870

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 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 mohan.com
#another host
127.0.0.1 test.loc
127.0.0.1 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 google.com 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 google.com and on the right google.temp
EDIT:

Add this to a .htaccess for those redirects.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*).test.loc
RewriteRule ^(.*)$ test.loc/%1 [L]
RewriteBase /

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme