Support Forums

How can I redirect one subdomain to another subdomain?

The forum is telling me I can only put 6 links in a post, so:
sc = studentcommunity.kaveergera.com
s-c = student-community.kaveergera.com
kg = kaveergera.com

I have a domain (kg) set up with Netlify. I already have a subdomain (sc) with different content set up using a branch on my GitHub repository. I’m trying to make s-c redirect to sc, but I can’t get it to work. I use Netlify DNS. I’ve tried adding a CNAME record to my configuration:

Name: sc
TTL: 3600 seconds
Value: s-c

but navigating to s-c just produces a “Not found” message.
I’ve also tried adding a netlify.toml file to the studentcommunity branch of my GitHub repository:

  from = "https://student-community.kaveergera.com"
  to = "https://studentcommunity.kaveergera.com"
  status = 301
  force = true

but that didn’t work. I also tried putting the same config file on my main branch, but that didn’t work either. I was trying to follow this documentation: Redirect options | Netlify Docs, but I’m not able to get it to work.

(Adding a domain alias for s-c in the domain settings redirects s-c to kg, not s-c to sc.)

I really appreciate any help. Thank you in advance!

I would add splats to these redirects, and/or verify that the _redirects file is at the top level of your site. The domain-level redirect should work.

Thanks for your response. I updated the netlify.toml file to this:

  from = "https://student-community.kaveergera.com/*"
  to = "https://studentcommunity.kaveergera.com/:splat"
  status = 301
  force = true

and removed the CNAME record I mentioned earlier. However, my browser now says it cannot reach the server for student-community.kaveergera.com or studentcommunity.kaveergera.com, which was working before. Any help on how to fix this issue will be greatly appreciated.

Also, which branch should the netlify.toml file be in?

Your redirect code looks correct. What happens when you re-enter that CNAME record?

I’ve re-added that CNAME record. This is now my current list of DNS records:

(The MX records are just to handle email.)

Both sc and s-c are still not reachable by my browser. I’m worried because I now have a larger problem than when I started, and I’m not sure why. Before, kg and sc both worked perfectly, and I just wanted a way to have s-c redirect to sc. However, now sc does not work (so I suppose I can’t be sure if the redirecting is working or not). We should probably try and fix the problem with sc first now, before we figure out the redirecting. Thank you so much!

sc has suddenly started working again. I’m not sure what made it work again though. My DNS records are attached above, and my netlify.toml file is also viewable above. Now the only problem to solve is the redirection from s-c to sc, so the major crisis has been averted; I’m grateful for your assistance.

I’m now in the same situation as earlier. With both the netlify.toml file and the CNAME record, s-c still says “Not found”. When I also add s-c under domain settings > custom domains > add domain alias, s-c just redirects to kg. How can I have s-c redirect to sc?

In the deploy summary for your site do you see something like the following about the processing of your redirect rules?


I don’t think I see it, but it’s possible I’m looking in the wrong place. Should I be looking at Netlify App ?

Select your site from Sites on your dashboard. Then select Deploys at the top of screen. Select the deploy that has Published next to it. Under Deploy Summary you will see the number of files uploaded, redirects, headers and other information about that specific deploy.

If you see No redirect rules processed then there was an issue with the syntax, or location of the file.

@coelmay I apologize, I found the section you are talking about.

It says it processed correctly.

Quite alright.

What if you change student-community.kaveergera.com from a CNAME to an alias so it is configured in Netlify like studentcommunity.kaveergera.com is?

studentcommunity.kaveergera.com is configured as a branch deploy because the content for it is on a different branch of my git repository. As far as I know, it doesn’t have an ALIAS DNS record. Perhaps I’m not understanding you correctly; are you suggesting I create an ALIAS DNS record for student-community.kaveergera.com?

Also, should I then keep student-community.kaveergera.com as a “domain alias” or remove it?

Apologies for not responding @Reevak05.

I tried to replicate your setup using a spare domain but was unable get the configuration the same :thinking:

Hey there, @Reevak05 :wave:

Welcome to the Netlify Forums :netliconfetti: Are you still experiencing issues here? If you are, please let us know and also include any changes or additional troubleshooting that you did in the past week. Thank you!