Your code would run from http://localhost/greenmugcafe/
if you changed the virtual host directory of localhost to C:/Users/Robert/Documents/GitHub/
Personally, I think it would be better to create a local domain called greenmugcafe.dev rather than having a folder greenmugcafe in the localhost domain.
How to setup virtual hosts in WAMP
Make sure virtual hosts have been enabled:
- Edit
/installdir/apache2/conf/httpd.conf
- Search for line that includes
httpd-vhosts.conf
and uncomment it by removing the # at the start
Adding a new virtual host:
- Edit the
hosts
file on your windows system (usually located atC:\WINDOWS\system32\drivers\etc\
) - Add the following to the end of the hosts file
127.0.0.1 greenmugcafe.dev
. This tells your computer that any url with a value ofgreenmugcafe.dev
should be routed to127.0.0.1
(aka localhost). - Save the
hosts
file and now edit this file/installdir/apache2/conf/extra/httpd-vhosts.conf
- Add the greenmugcafe.dev virtual host entry at the bototm of the
/installdir/apache2/conf/extra/httpd-vhosts.conf
file, save, and restart the server.
Here's the code:
#greenmugcafe
<VirtualHost *:80>
ServerAdmin webmaster@greenmugcafe.dev
DocumentRoot "C:/Users/Robert/Documents/GitHub/greenmugcafe/"
ServerName greenmugcafe.dev
ErrorLog "logs/greenmugcafe.dev-error.log"
CustomLog "logs/greenmugcafe.dev-access.log" common
<Directory "C:/Users/Robert/Documents/GitHub/greenmugcafe/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
Now http://greenmugcafe.dev will point to C:/Users/Robert/Documents/GitHub/greenmugcafe/
This method will also work for other WAMP stacks like Wamp Server and XAMPP.
For a launched website on a linux server, instead of the windows host file, we would change the a record
of the domain name to point to the server IP address. Then we still need to setup the virtual host so the server knows to recognise the domain name and point it to the correct folder on the server.
Hope that helps :-)