Monday, July 23, 2012

Set index.php as default page

I was programming a Web app and I noticed that always insert address of Web app, I had to type "www.mywebapp.com/index.php" to show up a web page. If I just type the next address "www.mywebapp.com", the Web server (Apache) list the directories and some files.

I would rather type "www.mywebapp.com" and same time the Web server show up the index.php. But how can I do that? Just follow the next steps:

  1. Open notepad and write the next statement "DirectoryIndex index.php"
  2. Save file as
    • Write name of file as ".htaccess"
    • Change type of file from " Text file (*.txt)" to "All files (*.*)"

Note: You must save the file on the same folder where is "index.php". If you don't save on the same folder, it will not work correctly.

Conclusion: The DirectoryIndex command allows specify a default page to display.

No comments:

Post a Comment