问题原文
原帖链接 · GeekRider · CC BY-SA 4.0
There's this weird issue that's been keeping me wondering what's happening. I apologize for the lack of specificity, but I need to abide to a strict NDA policy. So here goes my question:
Is there any way to pinpoint the source of redirection that's occurring when accessing a no-more-existing subdomain of a website that I'm managing?
Basically, http://oldsubdomain.example.com is being redirected to http://example.com. Moreover, Google doesn't allow me to remove it (through Search Console) from their search database specifically because of this redirection.
Despite the fact that the subdomain - which used to be in place many years ago - was deleted at some point a few years back and hasn't been used ever since, Google still seems to have it cached. However, the title, as well as the description of the search result snippet are identical to the main domain name result, i.e. by googling for http://oldsubdomain.example.com, I'm getting exactly the same result as when searching http://example.com.
Yes, I did search and couldn't find any directives in .htaccess that may cause such redirection, I also made sure (by checking under cPanel subdomain settings) that the subdomain doesn't exist. There are also no DNS records related to that obsolete subdomain in Cloudflare.
To sum it all up, how could I see exactly what is causing the redirection? I just want to disable it so that I can ask Google to remove the http://oldsubdomain.example.com search result.
已采纳解答
原帖链接 · MrWhite · CC BY-SA 3.0
In any case, I tried to deny access to
http://oldsubdomain.example.comthrough a .htaccess directive:RewriteRule ^oldsubdomain.example.com - [F]To my surprise, for some reason the directive is ignored. The reason as to why it doesn't work is still puzzling me. And by "doesn't work", I mean the redirection still occurs, as if the directive didn't exist.
The RewriteRule pattern matches the URL-path only, not the host. To match the host you need to use a RewriteCond directive and check against the HTTP_HOST server variable.
For example:
RewriteCond %{HTTP_HOST} ^oldsubdomain\. [NC]
RewriteRule ^ - [F]
However, it may be preferable to return a "410 Gone", instead of a "403 Forbidden" in order to get this removed from Google. In which case, simply change [F] to [G] in the RewriteRule flags.
I basically have a DNS-based
*.example.comwildcard redirect directive which was pointing to the root domain.
Since you didn't appear to be aware of this wildcard subdomain, are you actually using it? Can I link to anything.example.com and be redirected?
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
