Page is a not externally linkable
- Code, Content, and Presentation
-- Apache Web Server
---- Canonicalization: best code to redirect no-www to www & index to /


ewwatson - 8:46 pm on Oct 15, 2012 (gmt 0)


Ive been reading on this for days. All the ones in this forum as well. the .* seems pretty typical I thought. I tested it it works. here is what I have now...

# Engine on only need once
RewriteEngine On
# 301 permanent redirect index.html to root (including subdirectories)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html?\ HTTP/
RewriteRule ^(.*)index\.html?$ /$1 [R=301,L]
# 301 permanent redirect from non-www to www
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


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