How to redirect any subdomain to main domain?

If any user visits “blabla[dot]domain[dot]com”, the user should be redirected domain[dot]com

I tried creating a rule that *[dot]domain[dot]com to domain[dot]com is not working[dot]

Domain has no hosting, domain is only used for redirection[dot]

For example, domain[dot]com to domain[dot]com[dot]tr

Create a wildcard DNS entry:
A * 192.0.2.1

Create a redirect rule…
https://dash.cloudflare.com/?to=/:account/:zone/rules/redirect-rules

This will redirect any subdomains to the apex domain as in your first paragraph.

If you want to include the apex domain if you are forwarding to a different domain (as in your last paragraph)…
Also add an A record for @ pointing to 192.0.2.1
Remove the dot in the front of .example.com in the redirect rule

3 Likes

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