anonymous
anonymous

Reputation: 61

Apache VirtualHost configure

After I configured virtual host, my apache document root changed to the virtual host's document root, I just want to know why.

here is my httpd-vhosts.conf:

<VirtualHost *:80> 
   ServerName myapp.zend 
   DocumentRoot /opt/lampp/htdocs/php_zend_projects/myapp
   <Directory /opt/lampp/htdocs/php_zend_projects/myapp/public> 
      DirectoryIndex index.php 
      AllowOverride All 
      Order allow,deny 
      Allow from all 
      <IfModule mod_authz_core.c> 
         Require all granted 
      </IfModule> 
   </Directory> 
</VirtualHost>

After I restart apache server, localhost page changed to index of /opt/lampp/htdocs/php_zend_projects/myapp,

http://gwjyhs.com/t6/702/1556725814x2728329017.png

but it is supposed to be xampp's default page like this:

http://gwjyhs.com/t6/702/1556726269x2728278877.png

Upvotes: 0

Views: 65

Answers (1)

xate
xate

Reputation: 6379

If you enable vhosts you have to add an entry that looks like:

<VirtualHost *:80>
    DocumentRoot "F:/Dev/xampp/htdocs"
    ServerName localhost
</VirtualHost>

Note: change path to whatever is appropriate for you.

Restart webserver and it should work as before.

Reasoning behind this can be found in a comment on top of the httpd-vhosts.conf:

The first VirtualHost section is used for all requests that do not match a ##ServerName or ##ServerAlias in any block.

That means when you type in localhost it fallbacks to your myapp.zend vhost because it is (probably) the first virtualhost section.

Upvotes: 1

Related Questions