Redirect all third level that that do not exist on an existing domain

Hi all,
The question is pretty simple, is it possible to redirect all subdomains that not exist on an existing one?

For example:

  • Domain: example .com
  • Existing domain: exist. example .com
  • Non existing domain: something. example .com

I would like to redirect from something. example .com (generically from *.example.com) to exist. example .com or example .com.

I tried with using asterisk but it not work. Any idea?

Thanks in advance.

Grettings,

Thank you for asking.

May I ask why would you redirect non-existing to an existing, rather than per default show the error “as-is”? :thinking:

For eaxmple if somone want’s to attack your website, would use all A-Z sub-domains tries over the non-existing ones and all of the requests would be redirected to your domain/website which is resolving correctly and would result in overloading your own server? Why sacrificing all that? :thinking:

Maybe you could achieve this by trying to add a wildcard * (apex) sign into the DNS tab of Cloudflare dashboard, but remember it affects even the sub-domains which you could already use.

Therefore, proxy this hostname by setting it to :orange: and then create a Page Rule with 301 Forwarding rule to match the needed *.domain.com/*.

I am really not advising you doing that and cannot confirm if it would work like stated.
Again, I am against doing this so far.
I am not aware if this is against some ToS and if this would result in violating some.

NOTE: After checking, this can work, but it requires an Enterprise plan due to the usage of wildcard * (apex).

So, I am afraid this so far unfortunately is not possible in your case.

Regarding the 2nd or 3rd or other level sub-domain, you would have to use a Dedicated SSL (provided by the Advanced Certificate Manager), otherwise you would end-up having an issue as described at the article from below:

2 Likes

Hi @fritex, thanks a lot for your answer. Thinking better about it you are totally right about the redirect in case of attacks. Mine was more of a heartiness but given the motivations I don’t think it’s worth it.

Thanks again and have a nice day.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.