301 Redirect from domain alias to primary domain subdomain

I have set up a _redirects file (site name thegist.netlify.app) in order to redirect one of my domain aliases to a subdomain of the primary domain. The file contents look like this:

https://thegistnews.ca/* https://ca.thegistsports.com:splat 301!

However this doesn’t seem to be have done anything. Both domains are registered externally but have been pointed to Netlify.

Figure this out? I am also trying to do this without any luck.

Still no luck, the domain alias is still just pointing to the primary domain and not the subdomain.

There must be some step or configuration I’m missing but I haven’t been able to find anything in the documentation.

Hey @samason,
Can you say more about what you’re trying to do? Do you want the URL in the address bar to change to one of these domain names or the other? Currently, thegistnews.ca is a domain alias of thegist.netlify.app:
https://app.netlify.com/sites/thegist/settings/domain#custom-domains

and ca.thegistsports.com also points to thegist.netlify.app:
https://app.netlify.com/teams/roslyn/dns/thegistsports.com#dns-settings

@sublet, if you want to share your current redirects and Netlify URL, we can take a look!

Hey @jen,
I would like when I go to thegistnews.ca that it redirects to ca.thegistsports.com, which is a branch deploy of the main site. Am I able to do that with the _redirects file?

Thanks @jen

https://bails.cc/* https://simplybail.com/m/:splat 301!

Basically bails.cc is a domain alias, and simplybail.com is the primary.

The other redirect I have is working and it says both rules processed.

@jen please let me know if I have the ability to set up the redirect from a domain alias to the subdomain of the primary domain. Thanks!

Hey @samason,
I escalated this to @fool and we both took another look today. Yes, you can redirect from a domain alias to a primary domain subdomain… and from what we looked at today, you seem to be doing it already? Is that not the case?

@sublet, we looked at your site too and your redirect is set up correctly. Your site is password-protected, so you’ll have to enter the password twice in order to get to the redirected site. But again, it seems like it’s working? It does seem like your site assets are not loading because, for example, https://bails.cc/style.css lives at https://simplybail.com/style.css, not https://simplybail.com/m/style.css. Here’s a thread on redirects with static assets that might be useful:

Let us know if you have other questions on this!

@jen Thanks for jumping back in here. The redirect actually wasn’t working until i took the password off but it looks like we are good to go now. Thanks.

2 Likes

@jen I believe I have it set up to do this correctly, however when I go to thegistnews.ca in my browser redirects to the primary domain without any subdomain.

Hi there :wave:t2:

I haven’t dug into this any further than my simple suggestion here, but any time we’re playing with 301’s, the 301 response is truly meant to imply that a redirect is permanent, and your browser may be caching that information …somewhat permanently. Can you hit your domain/path a couple of times from the CLI to ensure that you’re getting the correct redirect code(s) back with the correct Location header(s)?


Jon

1 Like

Ah thanks @jonsully, I probably should have checked if it was caching. It wasn’t properly redirecting in incognito mode so I assumed caching wasn’t the issue but I confirmed that it is properly set up and has the correct headers when hit.