Redirecting all Subdomins

Hello,

I did some googling and was not able to find the answer so I thought I would post my question here. I want to set up a redirect or rewrite that will send all subdomain requests to a new location. For example something like

https://*.mywebsite.com https://www.myothersite.com/test

Is this possible within Netlify?

@richp Welcome to the Netlify community.

Does this help?

Hello @gregraven,

I have read through that document a couple of times and I don’t see anywhere where wild card subdomains are discussed. If it is please let me know where because I am not seeing or getting it.

@richp Maybe I don’t understand what you’re trying to do. It looks from your example as though you are trying to redirect all traffic. What difference does the subdomain make? Just redirect everything.

Hello @gregraven,

I would not think it would make a difference. I am redirecting https:// oldsite.com https://www.mynewsite.com and if I type in oldsite.com it redirects just fine. But if I add a subdomain to the URL such as test.oldsite.com I get this:

Not found - Request ID: 4f867225-e090-4b9c-be25-36bf57e72b6b-153236028

I must be doing something incorrect if it is possible to redirect all traffic. When I read though the documentation I am not seeing where it talks of redirecting all domain traffic. Where does it state that in the documentation? I don’t see it in the section about domain level redirects. I am sure I am just blind or don’t get how Netlify uses the _redirects file.

@richp Is your new site on Netlify, too? How many subdomains are we talking about here?

@gregraven Yes. Quite a few as it was a multi tenancy application. Each customer got their own subdomain URL.

I believe you can add a star subdomain to a Netlify site (which should then let you write _redirects for it) but that’s something only an official support engineer can do for you, it’s not an option in the Netlify Admin UI to users. @perry do I have that correct?

–
Jon

@jonsully Do you know how I can go about getting the wildcard domain added to a site? Do I just send an email to support?

You could do that. I’ll go ahead and tag @perry in for help here as well :slight_smile:

Hi, @richp. Yes, this site is on a Pro level team and we provide helpdesk support for all plan types which are Pro (or higher).

I’m opening a ticket for this now. Please do reply here though if you do not see a email from us about the support ticket.

I’m also going to include our “standard verbiage” here so that other people interested will understand how this feature works at Netlify. “Standard verbiage” follows:

Wildcard subdomains aren’t enabled by default and can only be enabled from our end. There are a few requirements before we’re able to do so:

  1. Either you have to use Netlify DNS so we can get you a wildcard SSL cert, or you must bring a custom wildcard certificate.
  2. We can only do this for a site that’s on a paid team (see https://www.netlify.com/pricing#teams for details)

Also note:

  • You can’t use domain aliases on the site with Wildcard subdomains enabled, just the bare domain and subdomains under your primary domain. If you try to add a domain alias then it won’t work.
  • The primary custom domain for the site, if it is a “site.com+www.site.com” setting in our UI, must be www.site.com and NOT site.com!

Once the wildcard subdomain feature is enabled, you do not need to add new subdomains under the site settings. You’ll will need still need to create DNS records.

This might be a single wildcard DNS record for all subdomains (like a CNAME for *.example.com pointing to the netlify.app subdomain for the site). Alternatively, you can also create the individual DNS records to add each subdomain (like CNAMEs for subdomain-a.example.com , subdomain-b.example.com , etc.) as covered in our external DNS documentation. Both work so please do whichever you prefer.

Please also be aware that we do not current have any built-in method of doing server side “domain-specific” handling - for instance if you want a redirect to automatically redirect from x.yourdomain.com to a path of x based on that subdomain, you’ll have to do that in client-side JS (you can make hostname-specific redirects, but those require the full hostname to be input into each rule, which defeats the zero-config nature of this feature), so please share your use case with us if you are worried about any of the limitations above so you don’t spend time implementing to this feature only to discover limitations that block your use.

Assuming no questions, please let me know which site you’d like to configure with this feature, and I’ll verify that it meets the requirements and get that set up for you.

Again, I’m opening a support ticket so please reply to us there unless you don’t see that email from us.

1 Like

Hello @luke,

Thank you for opening a ticket. I believe we have a pro subscription and I have made sure on our site that www.site.com is the primary domain. I am currently debating on the SSL and if we should keep this site with the rest of our sites in regards to DNS and SSL or move this one site to Netlify. When do you need to have an answer in that regard?

Regards,

Rich

hey rich, because you have a support ticket open in the helpdesk, we are going to keep the conversation going with you there :slight_smile: I am going to close this thread to avoid duplication.