Msg#: 4673331 posted 1:27 am on May 22, 2014 (gmt 0)
I want blog.example.com and blog.example.com/any_garbage_here to redirect to www.example.com
I have put the following in my htaccess. index.html does go to root so that part is fine. non-www does go to www so that part is also fine. but blog.example.com does not go to example.com why is it not working? how do I modify this to get it to work?
Msg#: 4673331 posted 3:41 am on May 22, 2014 (gmt 0)
Do you have other subdomains that you need to keep? If not, you can simplify everything at this point by letting all redirects fall under a single domain-name-canonicalization rule. It looks like this:
Typically this will be your very last redirect, where the second-to-last is the index.html redirect. The rules you've quoted are out of order. If there are no surviving subdomains-- as implied by the quoted rules-- the index.html redirect is also a single line plus condition. (The condition may not even be needed if the [NS] flag works for you. Try it.) This one goes right before the domain-name rule.
Incidentally, forms like ^.* are never necessary. Just leave off the anchor along with the .* part. Personally I wouldn't use an [NC] here. If someone asks for "INDEX.html", let them get the 404 they deserve ;)