# Windows – How to create a fake hostname in windows

hostnamewampwindows

I was reading a book and it said that I can setup a fake hostname in windows by changing the file hosts present in C:/Windows/System32/Drivers/etc/ but it didn't say how to do it.

I mean like http://localhost/ directs me to my wamp home folder www I want to type http://something/ and let the browser directs me to a specific folder.

Does anyone has an idea how to do this ?

• You can't route web address to any folder on windows, http is a web protocol and must have a web server listening on other end. What you can do is to set up virtual host in Apache, preferably a subdomain, and make folder you want to be accessible from the web a DocumentRoot of that host. So:

In host file set

127.0.0.1 myfolder.localhost

and add these lines to httpd.conf, Apache configuration file (or extra/httpd-vhosts.conf, make sure it's being included by main httpd.conf)

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>
DocumentRoot "C:/webroot"
ServerName localhost
<Directory "C:/webroot">
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

<VirtualHost 127.0.0.1>
DocumentRoot "D:/myfolder"
ServerName myfolder.localhost
ErrorLog "D:/myfolder/logs/error.log" # if you want separate logs for this folder
CustomLog "D:/myfolder/logs/access.log" combined
<Directory "D:/myfolder">