August 24th in Linux/Unix by pbu .

how to change default homepage with htaccess?

It is easy to change the default homepage with .htaccess file. Normally the default homepage is index.htm or index.php.

what if you want to set the default homepage to some other file (say home.php) . All you have to do is create a .htaccess file in the public html folder with the following line.

DirectoryIndex home.php

It would be interesting to note that you can access the home.php with GET like this.

http://www.domain.com/?photo=254

which will be same as

http://www.domain.com/home.php?photo=254

This is a useful tip!

Tip 2

Sometimes you might want php to serve pages with different extension instead of default .php. For example you might want to setup home.do with php code in it and want php to serve this page.

Just place the following code in your htaccess and your default homepage is home.do

DirectoryIndex .do .htm .php
AddHandler x-httpd-php .do .php4 .php

Hope this helps!

Similar Posts:

Share and Enjoy:
  • del.icio.us
  • digg
  • StumbleUpon
  • Technorati
  • DZone
  • Facebook
  • FriendFeed
  • Reddit
  • RSS
  • Twitter

Leave A Comment.