Wamp vhost docroot always shows as c:\wamp\www not the vhost docroot
I have tried dozens of guides and read ton of information but I still can't find a fix for my problem. I have uninstalled, reinstalled and checked and double checked every possible issue.
The problem remains. No matter what change I make, document root ALWAYS show up as c:\wamp\www.
Even if I change the httpd.conf DocumentRoot to another path it still shows up as c:\wamp\www
What is strange is if the vhost was set up wrong, my index.php should not display. But in fact it does. And I have a line of code to echo the $_SERVER['DOCUMENT_ROOT']
and it ALWAYS shows as c:\wamp\www and not to ANY of the vhosts document roots I have assigned.
So the pages load, of course with errors. My pages ALL reference $_SERVER['DOCUMENT_ROOT']
and ALL work perfectly on my live sites.
So the bottom line is I have checked my configs backwards and forwards. / vs. \, hosts file is correct, document root paths are correct and point to actual folders that contain the correct files. I have played with every "standard" and non-standard possibility of config.
There must be some other element that's keeping this from working. Please help if you can.
Please don't suggest I try another config. I have tried them all.
Pleas开发者_如何学Ce tell me you know why this is happening and how to fix it. I have on script that almost did the trick but feel just short of the fix. I left a message for the poster and have not heard back from him.
I hope somebody here has a fix and not a suggestion to try yet another config. Unless you KNOW of the issue and have a fix, please don't reply. That might sound rude, but I have seen and tried all the configs.
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot C:\wamp\www\itsaboutwirelessnetworks
ServerName itsaboutwirelessnetworks.localhost
ServerAlias itsaboutwirelessnetworks
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot C:\wamp\www\computerstore
ServerName computerstore.localhost
ServerAlias computerstore
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot C:\wamp\www
ServerName localhost
ServerAlias localhost
</VirtualHost>
Is the config. Why can't I edit with carriage returns in comments?
in C:\Windows\System32\drivers\etc\hosts
add this line:
127.0.0.1 computerstore.local
in httpd.conf
, make sure this line is uncommented:
Include "conf/extra/httpd-vhosts.conf"
(this should point to where your vhosts file is)
your httpd-vhosts.conf
file should contain this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:\wamp\www
ServerName 127.0.0.1
ServerAlias localhost
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:\wamp\www\conputerstore
ServerName computerstore.local
ServerAlias computerstore.local
SetEnv APPLICATION_ENV development
SetEnv APPLICATION_DOMAIN computerstore.local
</VirtualHost>
If WAMP refuses to load up the vhosts file, move the vhosts config to the end of httpd.conf
instead.
This should enable name-based configuration instead of IP-based. If you don't set it this way, Apache will resolve your sites' paths by IP, and since you specify a single IP, identical to all virtual hosts, the last one will take precedence over the previous ones. Your last vhost's docroot is C:\wamp\www
- making the behaviour you describe absolutely normal.
UPDATE:
Since the document root C:\wamp\www\computerstore
is specified for the domain name computerstore.local
, remember to also go to http://computerstore.local
in your browser. If you try http://localhost/computerstore
, the domain name will be resolved as localhost
, and in the first vhost, its document root is set to C:\wamp\www
. computerstore
will be treated just as a subdirectory; the docroot will not be changed in this case.
Did you try placing C:\wamp\www\conputerstore between quotes?
As an example here is my vhost config:
<VirtualHost *:8082>
DocumentRoot "c:/wamp/www/test"
DirectoryIndex index.php
<Directory "c:/wamp/www/test">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
精彩评论