Forum Moderators: phranque
The idea is to set "index.html" as the default home page. Then any requests that come in for www.example.com/index.html are redirected to www.example.com/. The last part is to make sure that no matter how badly formed the request is, that it will be directed to use the "www" nameing convention -> "www.example.com/"
Thanks for your feed back on this:
DirectoryIndex index.html
Options Indexes FollowSymLinks Includes
RewriteEngine on
# Externally redirect requests for index.html in any directory to "/" in that directory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html$ http://www.example.com/$1 [R=301,L]
#
# Externally redirect requests for *all* non-canonical hostnames to canonical hostname,
# including case errors and appended FQDN indicator and/or port numbers.
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
[edited by: RedWine at 9:13 pm (utc) on July 6, 2009]
Hostnames in the FQDN form and/or including a port number are not "badly-formed," they are simply non-canonical.
Unless you wish the server to produce a directory listing of all files in subdirectories which do not include an index.html file, do not use "Options Indexes".
If you are worried about double redirects, use the Live HTTP Headers add-on for Firefox/Mozilla browsers to test your code.
Jim