Apache-2.2

設置 VirtualHost - 全部指向同一主機

  • June 7, 2015

我正在嘗試將我的域 yfcclub.ga 設置為文件夾/var/www/yfc,同時將 localhost 和所有其他域保留/var/www/html在 ubuntu 中。我的 vhosts.cof 文件是:

<VirtualHost _default_:80>
       DocumentRoot /var/www/html
       <Directory /var/www/html>
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>
       ErrorLog /var/www/html/error.log
       CustomLog /var/www/html/access.log combined
</VirtualHost>

<VirtualHost yfcclub.ml:80>
       ServerName yfcclub.ml        
       ServerAdmin webmaster@yfcclub.ml
       DocumentRoot /var/www/yfc

       <Directory /var/www/yfc>
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>


       ErrorLog /var/www/yfc/.errors/error.log
       CustomLog /var/www/yfc/.errors/access.log combined
</VirtualHost>

但是,所有域和 localhost 都指向var/www/yfc文件夾。我錯過了什麼嗎?

Change "VirtualHost" record.

<VirtualHost *:80>
...
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html
   <Directory /var/www/html>
           Options Indexes FollowSymLinks MultiViews
           AllowOverride All
           Order allow,deny
           allow from all
   </Directory>
   ErrorLog /var/www/html/error.log
   CustomLog /var/www/html/access.log combined
</VirtualHost>

<VirtualHost *:80>
   ServerName yfcclub.ml        
   ServerAdmin webmaster@yfcclub.ml
   DocumentRoot /var/www/yfc

   <Directory /var/www/yfc>
           Options Indexes FollowSymLinks MultiViews
           AllowOverride All
           Order allow,deny
           allow from all
   </Directory>


   ErrorLog /var/www/yfc/.errors/error.log
   CustomLog /var/www/yfc/.errors/access.log combined
</VirtualHost>

引用自:https://serverfault.com/questions/697154