.htaccess - Remove www but do not affect subdomain (htaccess) -
rewritecond %{http_host} !^mysite.com$ [nc] rewriterule ^(.*)$ http://mysite.com/$1 [l,r=301] this strips www url.
without rule subdomain works (blog.site.com). rule converts (site.com/blog) , shows 404 errors.
what need keep affecting subdomain(s)?
also, i'm curious if removing www. thing? i've heard doesn't matter long pick 1 , stick it. i'm using <link rel="canonical" ... /> re-enforce it.
with (blog\.)? @ begin blog. becomes optional , redirect if different blog.mysite.com , mysite.com.
rewritecond %{http_host} !^(blog\.)?mysite\.com$ [nc] rewriterule ^(.*)$ http://mysite.com/$1 [l,r=301] a different way same be:
rewritecond %{http_host} !^mysite\.com$ [nc] rewritecond %{http_host} !^blog\.mysite\.com$ [nc] rewriterule ^(.*)$ http://mysite.com/$1 [l,r=301] which means if hostname different mysite.com , blog.mysite.com redirect.
to avoid duplicity choose between www or non-www , redirect every thing that.
so if u use www redirect non-www www , vice versa.
Comments
Post a Comment