Change the default page of a directory

Discussion in 'Apache' started by Rashy, Feb 14, 2009.

  1. #1
    This article is on how to change the default page of any folder or directory

    Say the folder name is "abc" and the file we need to over ride instead of index.php is "default.php". So, you just have to create a .htaccess file in the "abc" folder n write the following code into it:
    
    DirectoryIndex default.php
    
    Code (markup):
    And upload it to "abc" folder.
    Bingo! You are done!

    Now in case you want to set preferences say load default2.php in case there is no default.php, then change the code to:
    
    DirectoryIndex default.php default2.php
    
    Code (markup):
    i.e. add pages in the decreasing order of there preference separated by a single space

    OR with more stability you can do like this:
    
    DirectoryIndex default.php default2.php index.php index.html
    
    Code (markup):
    Hope this article helps some of you :)
     
    Rashy, Feb 14, 2009 IP
  2. mortgageloan

    mortgageloan Peon

    Messages:
    339
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    thanks...that was a really helpful piece of information...
     
    mortgageloan, Feb 15, 2009 IP