大网数据广告活动
网站运营与故障问答

Strange redirection to root when trying to access subdomain

· 52CE 我爱测

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…

问题原文

原帖链接 · 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.com through 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.com wildcard 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?

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2018-03-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0 / CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。