My Web Hosting Manual


Home > .htaccess > Change Your Default Directory Page

Change Your Default Directory Page

So what is a "Directory Index"?

When you first open a directory, if nothing is specified, it should show you a list of files that it contains. Something like what Windows shows when you open a directory. On the internet, you usually don't want that. You usually want a page to show up. It your host probably does have it configured to be index.html or default.html. As in http://www.domain.com/directory/index.html. It would be the same as going to: http://www.domain.com/directory/. Why? Because the web server knows it should look for index.html and show it if nothing is specified.

That's cool, and that will work 99% of the time for you.

But what if you NEED to name it joe-plummer.html? No problem! Just include the following line to your .htaccess and set it to what ever you wish.

DirectoryIndex joe-plummer.html

The "joe-plummer.html" part can be what ever you want. and it will be treated as the default show page for EVERY directory.

You can also have a script become your page. or have different names just in case.

DirectoryIndex filename.html index.cgi index.pl default.htm joe-plummer.html

If you place such a line in your .htaccess and place it in your root directory, the following will happen when you go to http://www.domain.com/directory/:

  1. It will look for filename.html.
  2. If it doesnt find it, it will look for index.cgi
  3. If it doesnt find it, it will look for index.pl
  4. If it doesnt find it, it will look fordefault.htm
  5. If it doesnt find it, it will look for joe-plummer.html
  6. If it doesnt find it, it will either list all files in your directory, or show a page not found error depending on your hosts configuration.
Review It

You might also be interested in:






Top Hosting
  - Host Gator
  - Host Monster
  - Blue Host
  - Easy CGI
  - Lunar Pages
       
All content has been created by Juan Carlos Gorospe. These are my opinions and experiences.
Copyright © 2008, Juan Carlos Gorospe. All Rights Reserved.