0

I am trying to set my domain yfcclub.ga to folder /var/www/yfc while leave localhost and all other domains to /var/www/html in ubuntu. My vhosts.cof file is:

<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>

But, all domains and localhost point to var/www/yfc folder. Am I missing something?

1
  • You need named virtual hosts enabled .. before you try using this logic. Do you have it? NameVirtualHost *:80 Jun 7, 2015 at 3:10

1 Answer 1

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>
5
  • You mean replace _default_ with *?
    – X Pahadi
    Jun 7, 2015 at 0:48
  • 1. Remove #(comment) NameVirtualHost *:80 in conf file apache2 (httpd)
    – AntonMZ
    Jun 7, 2015 at 0:59
  • 2. Change <VirtualHost yfcclub.ml:80> --><VirtualHost *:80>
    – AntonMZ
    Jun 7, 2015 at 0:59
  • 3. Domain yfcclub.ml will take content for DocumentRoot /var/www/yfc
    – AntonMZ
    Jun 7, 2015 at 1:00
  • 4. All domains will take default page Apache
    – AntonMZ
    Jun 7, 2015 at 1:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .