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
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
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.
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:
A new manual deploy site at mysubdomain.mydomain.com with a _redirects file in the root folder
My primary manual deploy site at mydomain.com with a _redirects file in the root folder
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.
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:
add the domain forward-me.example.com to some site’s domain management settings
add a line in the file _redirects that says https://forward-me.example.com/* https://external-site-being-forwarded-to.com/ 301!
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?