设置 VirtualHost - 所有指向同一主机

设置 VirtualHost - 所有指向同一主机

我正在尝试将我的域名 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 [email protected]
        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>

但是,所有域和本地主机都指向var/www/yfc文件夹。我是否遗漏了什么?

答案1

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 [email protected]
    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>

相关内容