Home
Support Forums

Subdomain Redirects (To wrong deploy)

Hi!

My Netlify site name is habitat-caesium.netlify.app, and basically I am trying to get https://www.habitat.caesium.dev redirected to https://habitat.caesium.dev and https://www.staging.habitat.caesium.dev redirected to https://staging.habitat.caesium.dev.

As per initial support from Netlify, here my relevant settings for my Netlify domains:

and my _redirects file under /public in my repository:

https://www.habitat.caesium.dev/*  https://habitat.caesium.dev/:splat 301!
https://www.staging.habitat.caesium.dev/*  https://staging.habitat.caesium.dev/:splat 301!
/* /index.html 200

While https://www.habitat.caesium.dev is redirected to https://habitat.caesium.dev properly, https://www.staging.habitat.caesium.dev is being redirected to https://habitat.caesium.dev instead of https://staging.habitat.caesium.dev.

Any help is appreciated, thanks!!

Hey @chiahsoon,

Are you sure you’re seeing this? I tried your domain: https://www.staging.habitat.caesium.dev it doesn’t seem to be redirecting at all. I know this is not expected behaviour anyways, but wanted to make sure we’re on the same page before we debug further.

ah right i didn’t realize that, seems the (additional?) problem is like no there’s no redirection for both domains at all as well?

From what I see @chiahsoon neither www domain redirects to the non-www domain.

Additionally there is a CORS issue when visiting https://staging.habitat.caesium.dev/ (manually) not having access to staging.api.habitat.caesium.dev.

In all honesty, I would not configure the www subdomains, leaving only https://staging.habitat.caesium.dev/ and https://habitat.caesium.dev/.

Yup! I think we can ignore the CORS error for the staging subdomain because my backend isn’t actually online right now, meaning for https://habitat.caesium.dev I would expect to the the spinning home page, and for https://staging.habitat.caesium.dev I would expect to see just the spinner.

And yup, I just wanted to configure the www subdomain just in case potential users might forget that its not part of the domain :sweat_smile:

Oh I see what’s happening here. staging.habitat.caesium.dev is actually a branch deploy and that’s where you’ve deployed the redirects. On the production deploy (that’s serving www.staging.habitat.caesium.dev), the redirects do not exist. You might want to add the redirects to the production branch too.

This finally solves my problem, thanks to all @hrishikesh @coelmay and merry Christmas! :slightly_smiling_face: