vhosts not working on windows 7 using wamp
-
08-10-2019 - |
Question
i'm having trouble setting up vhosts on windows 7. i'm running wamp.
my host file includes:
127.0.0.1 local.tribune.com
i've included httpd-vhosts.conf from within my httpd.conf.
my httpd-vhosts.conf includes:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/Users/Name/My Documents/the tribune/website/local.tribune.com/"
ServerName local.tribune.com
</VirtualHost>
here's the weird thing..if i remove the 'My ' from the DocumentRoot, then going to localhost in a browser works and i can see phpmyadmin, but i can't see the contents of the directory because the path is incorrect. but soon as i put that 'My ' in the path, the wamp icon never goes white (it stays yellow), and i can't reach localhost or local.tribune.com.
soon as i remove the 'My ' again, localhost will work again.
i've seen multiple posts around this issue on wampserver.com and elsewhere, but none of them answered or resolved. most that are resolved are basic issues like not including or having deleted httpd-vhosts.conf, missing characters, etc.
Solution 2
solved it. was close before, but just missed it.
in windows 7, the path is NOT:
c:/Users/Name/My Documents/the tribune/website/local.tribune.com
but is actually:
c:/Users/Name/Documents/the tribune/website/local.tribune.com
to prove this, click at the end of a path in a windows explorer window, and the full path is displayed in plain text.
also, just because i've seen some disagreement online, in my experience:
- the drive letter is case insensitive
- the slashes can go either way
- trailing slashes have no effect
- path names CAN have a space in them
OTHER TIPS
Its never a good idea to have a space in your directory path. URL Encoding interprets it as: "%20%". I would suggest placing your website files on D:/websites/local.tribune.com
you can read more about URL Encoding here
Hope that helps