Forum Moderators: phranque
I registered a domain that has a number of backlinks to subdomains attached to the domain I purchased.
I don't use those subdomains anymore, nor do I know all the subdomains that the previous owner used to have.
Is there some kind of command that could be added to an htaccess file (or some other method) that would redirect traffic to ALL subdomains to another webpage on my domain.
Ideally, the redirection would occur, but the address field in IE would show the address of the url the surfer typed in.
Below is what I found on the net and tried without luck.
ErrorDocument 400 [yahoo.com...]
ErrorDocument 401 [yahoo.com...]
ErrorDocument 403 [yahoo.com...]
ErrorDocument 404 [yahoo.com...]
ErrorDocument 500 [yahoo.com...]
Thank you
Redirect permanent [sub.mydomain.com...] [yahoo.com...]
...I know it works for directories but I'm not sure if it works for subdomains like the way I demonstrate. Maybe it will. Wouldn't hurt to try. Or you could simply give them a 410 (resource gone):
Redirect gone [sub.mydomain.com...]
I don't imagine either of these examples will work, since .htaccess (as far as I understand it) will only cover the domain or subdomain it's on, but I could be wrong and these might work like a charm.
Welcome to WebmasterWorld [webmasterworld.com]!
> nor do I know all the subdomains that the previous owner used to have.
This is actually the key issue. You must be sure that your DNS is set up to 'point' all of those subdomains to your server. If not, requests for the undefined subdomains will return DNS errors.
> Is there some kind of command that could be added to an htaccess file (or some other method) that would redirect traffic to ALL subdomains to another webpage on my domain.
You can use mod_rewrite in .htaccess to test the %{HTTP_HOST} variable and extract the requested subdomain. After that, you can back-reference this subdomain in a RewriteRule. However, you'll have to specify exactly what you want to do with this; there are many, many options, and you can't write the code until you pick one.
For example, do you want to redirect all requested subdomains (other that "www", I presume) to the *same* "special" page, or do you want to redirect each subdomain to its own special page?
ALso, are you aware of the duplicate-content issues that doing this could cause? Search engines will typically drop all but one subdomain (the one *they* choose) and not list the others. However if there are dozens of subdomains leading to identical content, they may assume that you're trying some spammy "subdomain doorway page" trick, and penalize your site. To avoid this, it's best to redirect all extra subdomains to a page that explains that they are gone, and then redirect - manually or automatically - to your 'regular' web site using redirects that *do* update the browser address bar.
Jim
Thank you for your response.
>For example, do you want to redirect all requested >subdomains (other that "www", I presume) to the >*same* "special" page, or do you want to redirect >each subdomain to its own special page?
In regards to your question above, I would like to redirect all requested subdomains to the same special page.
Could you clarify what you mean by "other then www I presume"
Essentially, if someone requests [subdomain1.mydomain.com...] or www.subdomain2.mydomain.com, it would both go to the same page [mydomain.com...]
However, the url in the address bar would show the page that the user requested. In the above case, it would show either [subdomain1.mydomain.com...] or www.subdomain2.mydomain.com
I do know that the search engines won't like this, but I also see that many of the backlinks are from other webpages. These are what I want to preserve.
Thanks
This is usually a matter of semantics, but it bears on your situation here:
This is a domain name specifier with an http protocol specifier: http://example.com
This is a subdomain of that domain: http://www.example.com
What I'm saying is that "www" is a subdomain according to the definitions in use (such as when you register or check a domain in WHOIS).
The distinction is that you must register example.com, but you can then add any subdomains you like without further registration, e.g. www.example.com, test.example.com, www.test.example.com, etc. However, your DNS must be set up to 'handle' these subdomains.
So in this case, you want to redirect all subdomains except www.
Jim
Would you have a snippet of code that would meet my needs for this project?
Thanks
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www\.)?example\.com
RewriteRule .* /specialpage.htm [L]
Jim
In my case, I don't know what all the subdomains would be that the previous owner had but I'd like to catch the traffic from all subdomains and redirect.