Normally when I start a new web project, I just use “http://localhost/project_name_here” as the URL I run, and that’s worked for me. But recently, I started learning and working in Laravel, and one of the…uh… features, is that you have to navigate to the “public” folder. So your URL would be “http://localhost/project_name_here/public”. That was fine while I was learning, but I’m about to start a new project, and I don’t want that “public” in there.
I first thought about modifying the htaccess file and putting the “public/index.php” file into the root and changing the paths, but I decided to go the Apache VirtualHost route. Of course, since I’m using WAMP, most of the suggestions about VirtualHosts, like from Code Happy, don’t apply… and searching for WAMP VirtualHost shows as many solutions as there are results. So here’s what I did…
1) Go into your WAMP Apache config files. My wamp is located a c:/wamp, so the path to my config files is C:/wamp/bin/apache/Apache2.2.17/conf
a) open httpd.conf in a text editor
b) located the line
#Include conf/extra/httpd-vhosts.conf
And remove the first “#”
c) go into the extra folder, and edit the httpd-vhosts.conf file. Here’s what I added..
<VirtualHost *:80> ServerAdmin webmaster@terrymatula.com DocumentRoot "C:/Users/Terry/Dropbox/www/project_name/public" ServerName project_name.dev </VirtualHost> <Directory "C:/Users/Terry/Dropbox/www/project_name/public"> Options Indexes FollowSymLinks AllowOverride all # onlineoffline tag - don't remove Order Deny,Allow Deny from all Allow from 127.0.0.1 </Directory>
d) restart the Apache service
2) Edit the windows host file.
a) go into C:/Windows/System32/drivers/etc and open the file “hosts” in a text editor.
b) Just add one line:
127.0.0.1 project_name.dev
That got everything working perfectly for me.