Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- .htaccess redirects for index.html, index.php and index.htm to /


g1smd - 7:53 pm on Aug 16, 2012 (gmt 0)


I use something similar to this:

# Redirect index in any directory to root of that directory
RewriteCond %{THE_REQUEST} ^[A-Z](3,9)\ /([^/]+/)*index\.[^\ ]*\ HTTP/
RewriteRule ^(([^/]+/)*)index(\.[a-z0-9]+)?$ http://www.example.com/$1? [R=301,L]


# Redirect non-canonical hostname to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]


(\.[a-z0-9]+)?[^\ ]*\ HTTP/ is "period followed by some characters followed by stuff that is not a space then HTTP/" and simplifies to \.[^\ ]*\ HTTP/

Don't redirect only "example.com", as you miss redirecting "www.example.com:80"

The NC flag is unwanted.

(.*) captures everything, so anchoring is not required.

Do not escape periods in rule target.


Thread source:: http://www.webmasterworld.com/apache/4485314.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com