Strange redirection to root when trying to access subdomain
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.
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?
I must apologize for asking this question before making absolutely sure I'm not overlooking such an important thing as the wildcard subdomain redirect under the DNS settings! And I'm talking about the hosting's DNS, not Cloudflare's.
Now everything's crystal clear: I basically have a DNS-based *.example.com wildcard redirect directive which was pointing to the root domain. Hence, the requests to oldsubdomain (or any other one, for that matter) being forwarded to the homepage.
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.
Now if only I knew how to exclude specifically oldsubdomain from the DNS wildcard, so that I can still deny access to it without having to re-create it.
Any ideas? :)
I ended up asking the hosting provider to help me by adding a specific A-type DNS record, i.e. oldsubdomain.example.com, but they declined any responsibility, considering the fact that the website is using Cloudflare's services. Based on the response of the hosting representative, I went ahead and created a new A-type DNS record within the Cloudflare's DNS section, that points to the null 0.0.0.0 IP address, thus causing any potential HTTP request to oldsubdomain.example.com to fail immediately, especially since the non-existent oldsubdomain serves absolutely no purpose to the website.
I'm not sure whether my approach is the best long-term solution to my initial problem, but at least it works perfectly - as I was able to successfully perform a URL removal request under the Google Search Console - and it doesn't seem to cause any issues.
Thank you all for your useful input!
If you want to see which URL is redirect to your website, you can use the PHP parameter HTTP_Referer which tells you which URL sent you the traffic.
Comments
Post a Comment