I’d like to permanently redirect all traffic going to the default netlify subdomain to my set custom domain.
I noticed the netlify subdomain site was still live. Wouldn’t this cause duplicate content issues? I’ve tried adding redirect rules in the Gatsby redirects and netlify.toml files but nothing worked.
Yes. I don’t think it works because the domain is set to emTr0.dev so it’s not catching anyone going to the other. The netlify site doesn’t seem to be updating but it’s still there with some content that was posted before I set the custom domain.
I’m not sure how you arrived at that conclusion. I want subdomain.netlify.app to forward to mysite.dev. I don’t want the subdomain to remain live but since I can’t just shut it, I’d have to permanently forward it to mysite.dev.
None of the redirect or toml rules seem to work since netlify only sees the site being served at mysite.dev even though the other is still live (although with old content).
You can associate a custom domain you own with your netlify site either by using Netlify DNS OR by using the DNS that currently manages the site to point to the subdomain. I think that’s what you are looking for?
There isn’t a way to remove the Netlify site name in general.
You could set up a redirect as greg suggested, so IF someone should find the netlify site name and try and access that URL, they would be redirected.
I already have those redirect rules but they don’t seem to be working. I have both http/https but it still shows the old site at the subdomain link (without content and an old page).
Ok so I just tried going to a link by adding the slug to the subdomain version and it works so as long as someone is clicking a full link to a post or page, the wildcard will work. I tried adding redirect rules for the homepage but it still won’t work.
To summarize, the “:splat” on the target is only required if there is wildcard ("*") on source. Leave the splat on the second two rules and remove it from the first two above. Then trigger a new deploy to have the redirect changes take effect.
If that change doesn’t resolve this (or if there are other questions), please let us know.
@luke I removed the splat but emtr0-dev.netlify.app still isn’t forwarding. I tried with/without a trailing slash just to be sure. I also cleared browser cache and all that. Tried waiting for a little bit of time also but same result.
Did you resolve this or are you still seeing the issue? If you do not see these redirects working now, would you please send us an x-nf-request-id header (or the info it replaces) for a failed redirect?
Hi, @emTr0, we only responded with that x-nf-request-id once (they are unique). The timestamp was 1590373478.468 seconds after the Unix epoch which is Sun May 24 19:24:38 PDT 2020.
At that time, the following deploy was active (having completed less than two minutes before):
In that deploy, there were only two redirects active and neither was for the subdomain emtr0-dev.netlify.app. You can download the _redirects file used by clicking on the download deploy button on that page shown in the screenshot below:
Note the date and time of the request: Sun May 24 19:24:38 PDT 2020
Did you just get that x-nf-request-id? If so, I think it is because you have a service working locally which has that version of the page cached. I see the referrer header in original request was:
https://emtr0-dev.netlify.app/sw.js
This usually indicates a service worker (but not always). There is more information about unregistering a service worker at the topic below:
If there are other questions about this, please let us know.
Whatever was causing it to not forward must have cleared itself because it’s now forwarding for me the way it should. I consider this solved unless you would like more info for future reference.