Wamp vhost docroot always displays as c: \ wamp \ www, not vhost docroot

I tried dozens of guides and read a ton of information, but I still can’t find a solution to the problem. I uninstalled, reinstalled and checked and double checked every possible problem.

The problem remains. No matter what change I make, the document root ALWAYS displays as c: \ wamp \ www.

Even if I changed the httpd.conf DocumentRoot to a different path, it still displays as c: \ wamp \ www

Which is strange, if vhost was configured incorrectly, my index.php should not display. But actually it is. And I have a line of code for the echo $_SERVER['DOCUMENT_ROOT'] , and it ALWAYS displays as c: \ wamp \ www, and NOT ANY of the roots of the vhosts document that I assigned.

Thus, the pages load, of course, with errors. My ALL reference $_SERVER['DOCUMENT_ROOT'] and ALL pages work fine on my live sites.

So, on the bottom line, I checked my configurations back and forth. / vs. \, the hosts file is correct, the document root paths are correct and point to the actual folders containing the correct files. I played with every β€œstandard” and non-standard configuration option.

There must be some other element that does not allow this to work. Please help if you can.

Please do not suggest me try a different configuration. I tried them all.

Please tell me, do you know why this is happening and how to fix it. I'm on a script that almost did the trick, but feel like it is not. I left a message for the poster and did not hear an answer from him.

I hope someone has a fix, not an offer to try another configuration. If you do not know about the problem and do not correct the error, please do not respond. It may seem rude, but I saw 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> 

This is the config. Why can't I edit with carriage return in comments?

+4
source share
2 answers

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 indicate where your vhosts file is located)

your httpd-vhosts.conf should contain the following:

 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 the vhosts file, move the vhosts configuration to the end of httpd.conf .

This should include name-based configuration instead of IP-based. If you do not set it this way, Apache will allow your sites to have IP paths, and since you specify one IP address that is identical to all virtual hosts, the latter will take precedence over the previous ones. Your last vhost docroot C:\wamp\www - makes the behavior that you describe is absolutely normal.

UPDATE:

Since the root of the computerstore.local domain is the document root C:\wamp\www\computerstore , be sure 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 will be set to C:\wamp\www . computerstore will be considered as a subdirectory; in this case the docroot will not be changed.

+6
source

Have you tried installing C: \ wamp \ www \ conputerstore between quotation marks?

An example is my vhost configuration:

 <VirtualHost *:8082> DocumentRoot "c:/wamp/www/test" DirectoryIndex index.php <Directory "c:/wamp/www/test"> AllowOverride All Allow from All </Directory> </VirtualHost> 
0
source

Source: https://habr.com/ru/post/1346827/


All Articles