After spending 1 hour trying to figure out how to configure virtual hosts on my local projects installations in Windows 8.1 .. I finally got it working ; so I decided to write a quick tutorial about it 🙂
What we will create is a virtual host under the name; “myproject”. Change this to reflect your project alias name.
Edit hosts file
Open “hosts” file using Notepad or so with admin privileges (You need to open notepad as admin: “run as admin”, this way you can save the changes inside the hosts file) and add the following to its end;
Save it and close.
Allow Virtual Hosts in httpd.conf
I’m using wampserver so to edit this apache configuration file, i left click on wamp tray icon and Apache -> httpd.conf. This opens the file in notepad.
# Virtual hosts # Include conf/extra/httpd-vhosts.conf
and comment out
This enables virtual hosts on Apache.
Add and configure virtual hosts individual projects
Now the only thing left to do is to add our projects to the httpd-vhosts.conf file located, depending on your setup in;
In this file, some tutorials recommand adding localhost to the list of virtual hosts, like so;
<VirtualHost *:80> DocumentRoot "d:/www" ServerName localhost ServerAlias localhost <Directory "d:/www"> AllowOverride All Require local </Directory> </VirtualHost>
Then at the bottom of it, you add your project
<VirtualHost *:80> DocumentRoot "d:/projects/myproject" ServerName zaintest <Directory "d:/projects/myproject"> AllowOverride All Require local </Directory> </VirtualHost>
After you have done all the steps, restart wampserver for the configuration to be set.
That’s it you have a running virtual host 🙂