Forward a subdomain to an external site with Netlify DNS

I’m using Netlify’s built in DNS tools, but I can’t figure out how to create a subdomain which then redirects it to an external site.

I need subdomain.mydomain.com to redirect to an external site https://externalsite.com - in other words, basic site forwarding on the subdomain level.

In this case it’s community.mydomain.com to go to an external discussion tool with a domain that I do not control.

Do I create a netlify.toml file or _redirects file or something of that nature?

I tried creating an CNAME alias in Netlify’s DNS and it defaulted to my-site.netlify.app and I couldn’t edit the forwarding there.

Do I create the CNAME alias and then come up with a _redirects file?

If so, I’ll need basic instructions to set this up. I’m still new. Thanks in advance!

If you are using Netlify DNS and wish to add a subdomain that points to a non-Netlify site you don’t use either the netlify.toml or _redirects to configure it. You need to add it under https://app.netlify.com/teams/[YOUR-TEAM-NAME]/dns.

If you attach the subdomain to a Netlify site and wish it to redirect to another location, you then add this to either a netlify.toml or _redirects file

@jasiqli can you please provide directions on what type of record and values to add once I get to the DNS page?

I tried both a CNAME and Alias and neither of them are forwarding.

Here’s what I put:

Record Type: Alias (also tried CNAME)
Name: community
Value: external-site.com

What am I missing here? Thanks!

Netlify DNS doesn’t offer the ability to forward. (And no, Alias and CNAME records are not used for that purpose. See Netlify Supported record types documentation and this article for an explanation of DNS record types.)

As you wish to have the subdomain act as a forwarder only and you are using Netlify DNS you will need to add the subdomain to a live site on Netlify as a custom domain. Once you have done this, add a redirect to a _redirects file in the form of

# [YOUR-SUBDOMAIN]              [WHERE-YOU-WANT-IT-TO-FORWARD-TO]
https://subdomain.example.com   https://www.example.net
2 Likes

@jasiqli getting closer…but now I’m getting ERR_SSL_VERSION_OR_CIPHER_MISMATCH in the browser :cry:

My Netlify DNS has a CNAME with:

NAME mysubdomain.mydomain.com
VALUE externalsubdomain.externaldomain.com

and my _redirects file reads:

/mysubdomain/* https://externalsubdomain.externaldomain.com/page/:splat 301!

and my SSL certificate in Netlify is properly setup as a wildcard to cover *.mydomain.com

The external site is hosted on https://notion.site so the SSL certificate should be valid and trustworthy.

I’m at my wits end…

What is the domain you are trying to configure?

With a CNAME the client (e.g. browser) will attempt to access mydomain.mydomain.com and expect a certificate for that domain, but is actually getting a certificate for externalsubdomain.externaldomain.com because a CNAME is NOT a redirect.

If you want a redirect do not use a CNAME. Instead create a manual deploy site at mysubdomain.mydomain.com (in Netlify) and create a _redirects file as @jasiqli suggested.

That is, point mysubdomain.mydomain.com at your manual deploy site where you have the _redirects file.

1 Like

@danielfdickinson1 that makes perfect sense, but still no dice.

I deleted the CNAME.

Then I set up a manual deploy site on my subdomain with a basic html page and _redirects file, but now the redirect won’t engage…it just loads the new subdomain html site that I uploaded.

I have:

  1. A new manual deploy site at mysubdomain.mydomain.com with a _redirects file in the root folder
  2. My primary manual deploy site at mydomain.com with a _redirects file in the root folder

The _redirects file in both places reads:

/mysubdomain/* https://externalsubdomain.externaldomain.com/page/:splat 301!

Thanks for your patience with me!

should be

EDIT (should be 301! not just 301)

https://mysubdomain.mydomain.com/* https://externalsubdomain.externaldomain.com/page/:splat 301!
1 Like

You may want to include the http version as well.

1 Like

It works!! :raised_hands:

@danielfdickinson1 @jasiqli you may now have a :cupcake: for your good deeds.

I just had to use a root wildcard on the subdomain.

The working _redirects file reads:

/* https://externalsubdomain.externaldomain.com/page/:splat 301!
/* http://externalsubdomain.externaldomain.com/page/:splat 301!

1 Like

Since you have used a root wildcard, I don’t think you need the second line (http). I forgot that your subdomain was the primary domain not a secondary domain you can use the root wildcard.

Oh wow, facing the exact same problem… I think I wouldn’t have switched my whole domain over to Netlify if I knew such basic functionality was missing.

Now I guess I have to revert everything I set up regarding the domain name server and hope my sites still work afterwards. It’s a real mess here, tbh. :confused:

Hi, @CRDev. Your post is high on criticism and low on detail. That said, I do think there is a solution here.

Please also note, these were two community members discussing an issue and no one from Netlify has ever replied in this topic before. So, please keep whatever was said above (which was also over a year and a half ago) with a grain of salt. It may not be accurate information above. That said, I am not sure what you think does not work because the last reply from the person with the issue was:

This is what I mean by “high on criticism and low on detail”:

Oh wow, facing the exact same problem

What problem? There are several different issues discussed above.

I think I wouldn’t have switched my whole domain over to Netlify if I knew such basic functionality was missing.

What functionality is missing. There is nothing above that Netlify cannot do with the correct configuration.

Now I guess I have to revert everything I set up regarding the domain name server and hope my sites still work afterwards. It’s a real mess here, tbh.

Again, I think you are racing ahead based on false assumptions. There is nothing here that Netlify cannot do.

I will attempt to give the correct workflow to forward a subdomain to some other site. However, as you have not clarified exactly what you are attempting, I do not know if this applies to your situation or not. If you have follow-up questions of if this workflow does not work for you, please let us know what the goal is here and include as much detail as possible when doing so.

What probably went wrong above

Again, no one from Netlify was involved in this thread before and the examples given are not for the real values so it it really hard to reconstruct what actually happened 19 months ago. That said, I’ll give it my best.

I am going to use the following domains as examples:

  • example.com: the example domain hosted on Netlify
  • forward-me.example.com: the domain that needs to 301 redirect to a site hosted outside of Netlify
  • external-site-being-forwarded-to.com : the external site we want to 301 redirect to

What I think happened is this:

  • they made a CNAME record for forward-me.example.com pointing to external-site-being-forwarded-to.com

This does not work because you must control the server at external-site-being-forwarded-to.com with this workflow. They were very clear they did not control the site being 301 redirected to so (if that is what they did) it was always going to fail.

The correct workflow

You only control the sites and domains you control. You cannot make CNAME records that point to domains you do not control and expect that work ever work. It just won’t.

The correct workflow here is to add the domain to 301 redirect to an existing site at Netlify and then add the 301 redirect rule to that site.

The steps here would be this:

  1. add the domain forward-me.example.com to some site’s domain management settings
  2. add a line in the file _redirects that says https://forward-me.example.com/* https://external-site-being-forwarded-to.com/ 301!
  3. make a new deploy of the site to add the new redirect rule above to the production deploy

If you are using Netlify DNS, then step 1 automatically makes the required NETLIFY type DNS record in the Netlify DNS zone for example.com. Step 2 creates the rule that causes any request to any URL starting with https://forward-me.example.com/ to the https://external-site-being-forwarded-to.com/ URL. Step three makes the rule live on the site at Netlify.

Would you be willing to please test that and let us know if it works for you or not? Also, if this is not your goal, would you please clarify what the goal is here?