Redirecting *.domain.com to domain.com

Hi guys,

I am hosting an app that let’s say is available at domain.com and I want to automatically redirect sub domains not defined by other apps to domain.com. I’ve already set up the CNAME records to do this, and have added *.domain.com as a custom domain along with domain.com to my app.

And it works like this: if I go to sub.domain.com I get to see the domain.com app, but the URL does not change to domain.com, it stays as sub.domain.com. How can I actually get sub.domain.com to redirect to domain.com?

I’m hoping my explanation is clear enough. Thank you for any suggestions!

Hi @bw-sergiu ,

There’s no Render feature for doing domain-level redirects, but we do have a feature request at Domain level redirects | Feature Requests | Render that you can upvote and follow to get updates.

The best solution available to you today is to do the redirect on your site itself, either server-side with an HTTP temporary redirect or permanent redirect, or client-side with a window.location redirect. If you detect that the host domain is a subdomain, your code can then do the redirect.

I’ve already upvoted that request.

Ok Dan, thanks for your feedback, we’ll try your suggested solution.