Set Your Directory Index (Homepage) Using .htaccess

As every web developer knows, the server default for a directory's default file is index.{extension}. Apache is usually set to index.php or index.html. It's a good practice to set your DirectoryIndex setting in your .htaccess file, especially if you're hosting your website on shared hosting. A hosting provider's guidelines could change at any time but your .htaccess file's directive would prevent any problem for you.

Another reason to use this property would be if your website were to go down for maintenance, or a section of your website. Here's how you can use this property.

The Code

DirectoryIndex index.php index.html site-down.php

Comments

  1. Steve

    Hello, I have 2 homepages (in the root folder): 1 in French (let’s say bienvenue.html), and 1 in English (let’s say welcome.html).
    If i set the English page as default via DirectoryIndex, then Google (.fr) Search Results will display the English (meta) contents – Welcome blablabla – when there’s a match with French search terms…

    I also have these 2 lines in htacess:

    Rewritecond %{HTTP_HOST} ^nicobalivillas\.com
    RewriteRule ^(.*)$ http://www.nicobalivillas.com/$1 [R=301,L]

    Could this be because of this redirection?
    Any hint on how to fix this so that the French version is displayed for search results matches in French?

  2. Steve

    Hello, I have 2 homepages (in the root folder): 1 in French (let’s say bienvenue.html), and 1 in English (let’s say welcome.html).
    If i set the English page as default via DirectoryIndex, then Google (.fr) Search Results will display the English (meta) contents – Welcome blablabla – when there’s a match with French search terms…

    I also have these 2 lines in htacess:
    Rewritecond %{HTTP_HOST} ^nicobalivillas\.com
    RewriteRule ^(.*)$ http://www.nicobalivillas.com/$1 [R=301,L]

    Could this be because of this redirection?
    Any hint on how to fix this so that the French version is displayed for search results matches in French?

  3. codefuture

    Thanks it works great! :) God bless you…

  4. ahmad balavipour

    Or using this:

    DirectoryIndex index.htm index.php


Be Heard!

Share your thoughts without being a jerk! And wrap your code in <code> tags, f00!

Name*:
Email*:
Website: