Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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

share|improve this question
    
You need named virtual hosts enabled .. before you try using this logic. Do you have it? NameVirtualHost *:80 –  Tim Brigham Jun 7 at 3:10

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.