Forum Moderators: phranque
So I've been talking to my host about redirecting all subdomains to point to the main domain.
For example blah.example.com will go to example.com.
I thought it would be as simple as using a wildcard, but my host says that it can cause a lot of problems.
I'm wondering if anyone here has experience with that, and can share what's worked for them?
Domain canonicalization is a very popular subject here (try a search on WebmasterWorld for that string), yet the number of resulting "problems" is very low -- with most of those probably due to what I refer to as "mis-implementation."
Balanced against the risk of splitting your search ranking across multiple hostnames such as www- and non-www, the risk of problems is negligible. When balanced against the potential for malicious linking when wild-card subdomains are possible/available with your current hosting and zone file configuration, the odds tilt overwhelmingly in favor of controlling what hostname your site is linked-to as and known by.
The above is based on the presumption that you and any sites you may control will not attempt to promote anything except the canonical domain name. If this is not the case, then the above is probably an off-target answer.
As far as implementation of the redirect, it takes two lines of mod_rewrite code in .htaccess or httpd.conf, and several other solutions are possible as well -- and the search suggested above will turn up most of them.
Jim
I do have code in my htaccess to prevent things like www vs non-www issues, however if someone were to type in "blank.mysite.com" they'd get an error message rather than be redirected.
My host said it could cause problems with Cpanel deleting the entry or something when I add new accounts.
Jim