title: apache2 virtual not working properly redirecting to 000-default.conf location
body: <p>i have managed to get 1 virtual host work before example.com and i didn't disable 000-default.conf. but both works perfectly if i use example.com it gives data from /var/www/html/example.com/public_html and if i use ip it gives /var/www/html</p>
  
  <p>recently i tried to add one more virtual host test.com did same process as before but now <code>if i use example.com it is giving /var/www/html/</code> even 000-default.conf is disabled.</p>
  
  <pre><code>if i use www.example.com it is giving /var/www/example.com/public_html  
  </code></pre>
  
  <p>and <code>newly added test.com also giving /var/www/html/ not /home/user/test.com/folder</code></p>
  
  <blockquote>
    <p>000-default.conf</p>
  </blockquote>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          # The ServerName directive sets the request scheme, hostname and port that
          # the server uses to identify itself. This is used when creating
          # redirection URLs. In the context of virtual hosts, the ServerName
          # specifies what hostname must appear in the request's Host: header to
          # match this virtual host. For the default virtual host (this file) this
          # value is not decisive as it is used as a last resort host regardless.
          # However, you must set it for any further virtual host explicitly.
          #ServerName www.example.com
  
  
          ServerAdmin webmaster@localhost
          DocumentRoot /var/www/html
          # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
          # error, crit, alert, emerg.
          # It is also possible to configure the loglevel for particular
          # modules, e.g.
          #LogLevel info ssl:warn
  
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  
          # For most configuration files from conf-available/, which are
          # enabled or disabled at a global level, it is possible to
          # include a line for only one particular virtual host. For example the
          # following line enables the CGI configuration for this host only
          # after it has been globally disabled with "a2disconf".
          #Include conf-available/serve-cgi-bin.con
  &lt;/VirtualHost&gt;
  
  # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  
  &lt;VirtualHost *:80&gt;
  
  &lt;IfModule mod_fastcgi.c&gt;
          AddHandler php56-fcgi-www .php
          Action php56-fcgi-www /php56-fcgi-www
          Alias /php56-fcgi-www /usr/lib/cgi-bin/php56-fcgi-www
          FastCgiExternalServer /usr/lib/cgi-bin/php56-fcgi-www -socket /run/php/php5.6-fpm.sock -pass-header Authorization
          &lt;Directory "/usr/lib/cgi-bin"&gt;
                Require all granted
           &lt;/Directory&gt;
      &lt;/IfModule&gt;
  
      &lt;IfModule mod_fastcgi.c&gt;
          AddHandler php71-fcgi-www .php
          Action php71-fcgi-www /php71-fcgi-www
           Alias /php71-fcgi-www /usr/lib/cgi-bin/php71-fcgi-www
           FastCgiExternalServer /usr/lib/cgi-bin/php71-fcgi-www -socket /run/php/php7.1-fpm.sock -idle-timeout 1800 -pass-header Authorization
           &lt;Directory "/usr/lib/cgi-bin"&gt;
                Require all granted
           &lt;/Directory&gt;
      &lt;/IfModule&gt;
  
      &lt;IfModule mod_fastcgi.c&gt;
          &lt;FilesMatch ".+\.ph(p[345]?|t|tml)$"&gt;
              #Uncomment the SetHandler you want to use by default
              #SetHandler php56-fcgi-www
              #SetHandler php71-fcgi-www
          &lt;/FilesMatch&gt;
      &lt;/IfModule&gt;
  
     Alias /var "/var/www/html/"
      &lt;Directory "/var/www/html/"&gt;
          &lt;FilesMatch ".+\.ph(p[345]?|t|tml)$"&gt;
              #Uncomment the SetHandler with the opposite php version
              #SetHandler php56-fcgi-www
              #SetHandler php71-fcgi-www
          &lt;/FilesMatch&gt;
      &lt;/Directory&gt;
  
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <blockquote>
    <p>example.com.conf</p>
  </blockquote>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          # The ServerName directive sets the request scheme, hostname and port that
          # the server uses to identify itself. This is used when creating
          # redirection URLs. In the context of virtual hosts, the ServerName
          # specifies what hostname must appear in the request's Host: header to
          # match this virtual host. For the default virtual host (this file) this
          # value is not decisive as it is used as a last resort host regardless.
          # However, you must set it for any further virtual host explicitly.
          #ServerName www.example.com
  
          ServerAdmin Admin@example.com
          DocumentRoot /var/www/example.com/public_html
          ServerName example.com
          ServerAlias www.example.com example.com
  
          # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
          # error, crit, alert, emerg.
          # It is also possible to configure the loglevel for particular
          # modules, e.g.
          #LogLevel info ssl:warn
  
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  
          # For most configuration files from conf-available/, which are
          # enabled or disabled at a global level, it is possible to
          # include a line for only one particular virtual host. For example the
          # following line enables the CGI configuration for this host only
          # after it has been globally disabled with "a2disconf".
          #Include conf-available/serve-cgi-bin.conf
  RewriteEngine on
  RewriteCond %{SERVER_NAME} =www.example.com [OR]
  RewriteCond %{SERVER_NAME} =example.com
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
  &lt;/VirtualHost&gt;
  
  # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  </code></pre>
  
  <p>thanks for taking a look at my problem please tell me where i did mistake </p>
  
  <p>or what could be wrong....
  thanks in advance</p>