how to change default homepage with htaccess?

Linux/Unix Add comments

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!

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • BlinkList
  • blogmarks
  • del.icio.us
  • digg
  • feedmelinks
  • Furl
  • Fleck
  • MyShare
  • NewsVine
  • Netscape
  • Slashdot
  • Spurl
  • StumbleUpon
  • Taggly
  • Technorati
  • Wists
  • YahooMyWeb

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login