title: localhost is showing index of when I added a virtual host in /usr/local/etc/httpd/extra/httpd-vhosts.conf
body: <p>I installed apache with brew and changed port <code>8080</code> to <code>80</code>. when I accessed <code>localhost</code> this shown me a page "it works!" and that page is located in <code>/usr/local/var/www</code> directory with file name index.html but when I added a virtual host in <code>/usr/local/etc/httpd/extra/httpd-vhosts.conf</code> file.</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
    DocumentRoot "/Users/ranaamir/projects/sample/yii2/backend/web"
    ServerName yii2.example.be
    ServerAlias yii2.example.be
    &lt;directory "/Users/ranaamir/projects/sample/yii2/backend/web"&gt;
        Options Indexes FollowSymLinks
        AllowOverride all
        Order Deny,Allow
        Allow from all
        Require all granted
    &lt;/directory&gt;
    ErrorLog "/usr/local/var/log/httpd/vjfBackenderror.log"
    CustomLog "/usr/local/var/log/httpd/vjfBackendaccess.log" common
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>and restart the service with <code>sudo apachectl -k restart</code> command and this host also added in <code>/etc/hosts</code>.</p>
  
  <pre><code>##
  
  127.0.0.1   localhost
  255.255.255.255 broadcasthost
  ::1             localhost
  127.0.0.1       yii2.example.be
  </code></pre>
  
  <p>Then I access <code>localhost</code> or <code>yii2.example.be</code> both are showing a page where only one line mentioned <code>Index of /</code>.</p>
  
  <p>if I remove code of block <code>&lt;VirtualHost *:80&gt;</code> from <code>httpd-vhosts.conf</code> then again <code>localhost</code> host showing correct <code>index.html</code>.</p>
  
  <p>why my project not running on the virtual-host url instead of <code>index of /</code>?</p>
  
  <p>Any help would be so appreciated!!</p>