phpapacheubuntuvirtualhostscalr

Site requires base url to include index.php for it to work


We are testing our using scalr. We have a site set-up in the folder /var/www/subdomain.example.com/public_html with the following virtualhost config:

<VirtualHost *:80>
       ServerAlias www.{$host} {$server_alias}
       ServerAdmin {$server_admin}
       DocumentRoot {$document_root}
       ServerName {$host}
       ErrorLog {$logs_dir}/http-{$host}-error.log
       CustomLog {$logs_dir}/http-{$host}-access.log combined
</VirtualHost>

When we goto subdomain.example.com it displays the hosts default message e.g. "Welcome to Scalr" - but if we go to subdomain.example.com/index.php the site is working. Is there a way to get the base url to direct to the index.php without showing it?


Solution

  • Have you tried:

    DirectoryIndex index.php
    

    More resources on that: http://httpd.apache.org/docs/2.2/mod/mod_dir.html

    In your case:

    <VirtualHost *:80>
      # (other directives)
      DirectoryIndex index.php
    </VirtualHost>
    

    Update

    As jcjr suggested, this directive can be also put inside .htaccess file, but ensure, that you've enabled such method by proper AllowOverride directive value:

    http://httpd.apache.org/docs/2.2/mod/core.html