I have got Ubuntu 12.04. I have a file index.html in apache'd document root but apache lists all the files when I access the document root from the browser.

It works fine if I replace index.html by index.php.

My /etc/apache2/sites-enabled/000-default:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

DocumentRoot /home/test/www
<Directory /home/test/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options   MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from ::1/128


I have /etc/apache2/mods-enabled/dir.conf:

<IfModule mod_dir.c>

          DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm


I did lot of searching but don't know my why index.html is not working and is getting listed in the browser.

If I keep both the files (index.html and index.php), then index.php works fine.

Here is the output of ls -l /home/test/www:

total 1816236
-rw-r--r--  1 root   www-data          3 Jun  3 10:09 index.html
-rw-r--r--  1 ubuntu www-data         53 Mar  4 16:55 index.php
drwxrwsr-x  5 ubuntu www-data       4096 May 12 05:03 lifetimeholidays
-rw-r--r--  1 root   www-data 1859796992 May 29 10:32 magentolive17_4_2014.zip
drwxrwsr-x 15 ubuntu www-data       4096 May 28 15:22 railsapp
drwxr-sr-x 15 root   www-data       4096 May 28 17:15 railsapp1
drwxrwxr-x  2 ubuntu www-data       4096 Apr 29 09:05 var
  • Can you paste the output of ls -l /home/test/www – Flup Jun 3 '14 at 10:56
  • I have updated my question that now shows the output of the above command. – Tarun Garg Jun 3 '14 at 11:00
  • Thanks Christopher. It solved my problem. I had an .htaccess file which was overriding my apache configurations. – Tarun Garg Jun 3 '14 at 11:14
  • But index.php is not getting opened by default now if I keep only index.php. – Tarun Garg Jun 3 '14 at 11:28
  • I finally changed AllowOverride All to AllowOverride None to get everything working. – Tarun Garg Jun 3 '14 at 11:37

Do you have a .htaccess file in /home/test/www/? The AllowOverride All stanza would allow the reading of that file, which is an Apache dynamic configuration file for that directory. It's contents override the configuration directives in /etc/apache2/sites-enabled/000-default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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