Apr
20
htaccess Explicitly Define Default Index File
April 20, 2008 |
When a surfer accesses your website, the server checks the root folder for an index file. Some examples of common index files are: index.html, index.htm, index.php, index.cgi, index.pl. The supported index files depend on the how the server is set up.
Your default web hosting server might be set to:
DirectoryIndex index.html index.shtml index.php index.htm default.html Default.htm default.html Default.html default.shtml Default.shtml page1.html index.pl index.cgi index.php3 index.phtml home.htm home.html home.shtml index.wml
As long as you name your “index” file any one of those things, it will work!
If you have two files with names from that list, Apache will show the one that shows up first (e.g. index.htm will show up, even if you have an index.php file in the same directory).
You can change your own DirectoryIndex setting to be anything you’d like via an .htaccess file too!
If the server cannot find an index file, it will try to display an index of all the files within the current directory, however if this is disabled, the server will end up displaying a 403 forbidden error. Using .htaccess, you can use a completely different index file instead of the defaults set by your server host (if you are using a hosting plan). To do this, insert the following line into an .htaccess file:
DirectoryIndex pagename.html second-choice.html third-choice.php
Change pagename.html, second-choice.html third-choice.php to the page that you would like to use as the index file.
Hope this helps!
Similar Posts
- Use htaccess to Deny Access Directory Listing
- Use htaccess to Fake Different File Extension
- Create Custom Error Pages Using htaccess PHP
- Force Files Like PDF Download using htaccess
- Block people from Certain URL Using htaccess
- htaccess gzip for Faster Loading and Bandwidth Saving
- Use htaccess for 404 Redirect
- htaccess Conditional Loop Redirect
- Use htaccess with Site Maintenance Page
- htaccess Permanently redirect file or directory
- Set Local Timezone Using htaccess
- Google Text Translation Using htaccess
- htaccess Remove the www From Domain URL
- Block IPs Using htaccess
- Use htaccess to Deny Access to hidden Files
- htaccess Require the www For Domain URL
- Apache htaccess Prevent Users from Uploading and Executing Files
- htaccess Limit the Number of Concurrent Visitors to your Website
- htaccess Deny Diractory Access During a Specific Time
- Deny Access to inc Files Using htaccess
- Remove File Extension Using htaccess
- Useful mod_rewrite Resources
Comments
2 Comments so far



















How does one create .htaccess and .htpasswd on Linux Terminal without accessing 3rd party sites who help in generating encrypted passwords
Harjit Singh Ubhi
Hi, Harjit Singh Ubhi
If you have shell access, run the following command:
/usr/bin/htpasswd -c ~/.htpasswd USERNAME
Replace USERNAME with the username of the user you wish to add (such as Patrick). You’ll be prompted to enter a password for the user. Just type any password you want, hit enter. The password will be automatically encrypted.