Change Default Directory Page

If you want to change your default directory page from “index” to something else, and you’re on an Apache Server, with Mod_rewrite installed, you can add this code to your .htaccess file:

DirectoryIndex otherpage.html

You can also set it up so that if the default page isn’t found that another takes its place:

DirectoryIndex otherpage.html differentpage.html

Of course, use the appropriate file extension for your web pages [.html, .php, etc.]

…or you use a simple redirect in the default page:


< ?php
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: http://'.$_SERVER['HTTP_HOST'].'/otherpage.php' );
?>

Comments are closed.