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 - 11:51 pm on Oct 15, 2012 (gmt 0)


Uh-oh I have a major problem. This htaccess is in the root of my top level domain. I have 4 other addon domains. Not subdomains. With this code in place when I go to the addon domain it forces it to read in the url http: //www (dot)topleveldomain(dot)com/addondomain(dot)com. Is there a fix for this? Because now that I see it the addon domains are essentially folders in root domain.

here is my exact code...

# Engine on only needed once
RewriteEngine On

# 301 permanent redirect index.html(htm) to folder
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ http://www.example.com/$1 [R=301,L]

# 301 permanent redirect non-www (non-canonical) to www
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
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