Change your default directory page

Some of you may be wondering, just what in the world is a DirectoryIndex? Well, grasshopper, this is a command which allows you to specify a file that is to be loaded as your default page whenever a directory or url request comes in, that does not specify a specific page.

Tired of having come up when you go to Want to change it to be that comes up instead? No problem!

كود PHP:

DirectoryIndex filename
This would cause filename.html to be treated as your default page, or default directory page. You can also append other filenames to it. You may want to have certain directories use a script as a default page. That's no problem too!
كود PHP:

DirectoryIndex filename
.html index.cgi default.htm 
Placing the above command in your htaccess file will cause this to happen: When a user types in, your site will look for filename.html in your root directory (or any directory if you specify this in the global htaccess), and if it finds it, it will load that page as the default page.

If it does not find filename.html, it will then look for index.cgi; if it finds that one, it will load it, if not, it will look for and the whole process repeats until it finds a file it can use. Basically, the list of files is read from left to right.

Every once in a while, I use this method for the following needs:

Say I keep all my include files in a directory called include, and that I keep all my image files in a directory called images, I don't want people to be able to directory browse through them (even though we can prevent that through another htaccess trick, more later)

I would specify a DirectoryIndex entry, in a specific htaccess file for those two directories, for /redirect/ that is a redirect page (as explained here) that redirects a request for those directories to be sent to the homepage. Or I could just specify a directory index of and upload an file to each of those directories. Or I could just stick in an htaccess redirect page, which is our next subject!