Enable wildcard subdomains

Can I set wildcard subdomains to redirect to the main domain?

For instance, anything.mydomain.com goes to mydomain.com.

There is no way to do this with a standard setup, but if you use Cloudflare there are Page Rules after you set it all up, where you can make wildcard redirects.