As @Verhoeckx said, it depends on your hosting provider. Who is it ?
If you are using Netlfiy, you can use _redirects file and and something like this:
# Redirect default Netlify subdomain to primary domain
https://ajeet.netlify.com/* https://ajeet.dev/:splat 301!
If you have addedd your domain in Cloudflare, it is easy. Use this guide:
https://support.cloudflare.com/hc/en-us/articles/200172286-Configuring-URL-forwarding-or-redirects-with-Cloudflare-Page-Rules