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 - 9:08 pm on Jan 11, 2013 (gmt 0)


I'm back! New issue with same code. If I don't have a index file in one of the addon domains it redirects to the main domain. Is this normal behavior for the below htacces code? Or is something amiss? Thanks

# 301 permanent redirect index.html(htm) to folder with exclusion for addon domains
RewriteCond %{HTTP_HOST} !(addondomain\.com|addondomain\.com|addondomain\.com|addondomain\.com|addondomain\.com)
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)index\.html?$ ht tp://w ww.maindomain.com/$1 [R=301,L]

# 301 permanent redirect non-www (non-canonical) to www with exclusion for addon domains
RewriteCond %{HTTP_HOST} !(addondomain\.com|addondomain\.com|addondomain\.com|addondomain\.com|websitecodetutorials\.com)
RewriteCond %{HTTP_HOST} !^(www\.maindomain\.com)?$
RewriteRule (.*) ht tp://w ww.maindomain.com/$1 [R=301,L]

Note I put spaces in the main domain - I forgot the domain to use to bypass that.


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