Stop directory listing


I have a .htaccess file with the following content in the public_html folder:

DirectoryIndex index.php
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* showpage.php [QSA,L]

All is fine and the site is working fine.

I then created a sub-folder called “demo” and when i uploaded files in it …instead of showing index.php by default its showing directory listing.

I tried to put another .htaccess file in the “demo” folder but it does’nt seems to be working. The code .htaccess file had:

DirectoryIndex index.php
RewriteEngine Off

How to stop showing directory listing and start loading index.php by default ?


to turn off the directory index you’d normally use

Options -Indexes

in an .htaccess file.
That doesn’t explain why it won’t show the DirectoryIndex though.
What if you put the code above, plus the DirectoryIndex code in the .htaccess in the root?