Thanks for your answer but the redirect is still not operational. When I click on the Netlify subdomain address it still points to the subdomain address and doesn’t redirect to the primary custom domain.
Hi, @Sujay, again this is not what I see when testing.
I see there is a service worker for this site. I suspect the local service worker is preventing the HTTP request from reaching Netlify and blocking the redirect. The redirect doesn’t occur because the browser doesn’t even make the HTTP request (at least that is my hypothesis).
Would try unregistering that service working and trying again?
If that doesn’t resolve the issue, we will need more information to troubleshoot.
The most specific information to send us the x-nf-request-id header which we send with every HTTP response. There more information about this header here:
If that header isn’t available for any reason, please send the information it replaces (or as many of these details as possible). Those details are:
the complete URL requested
the IP address for the system making the request
the IP address for the CDN node that responded
the day of the request
the time of the request
the timezone the time is in
With those details we’ll be able to find out why the redirect isn’t occurring. If there are questions about any of this, please let us know.
Thanks for your response. I unregistered the service worker but the redirect from the Netlify subdomain to my primary custom domain was still not working. Hence I have restored the service worker because Google appreciates websites that work offline, a feature that service workers facilitate by making the website more resistant to bad network conditions. So I need to keep the service worker operational.
Please find the x-nf-request-id for the base URL of the Netlify subdomain.
That request ID was served on 11 March, though you wrote in on 13 March. Pretty sure it the misbehavior for you is still service worker + caching related - the redirect is working well for everyone else without cache (even upon return visits)
I had made the request on the same day as I wrote my response i.e. 13.03.2020 strictly following Luke’s article mentioned above. What is reassuring is that I checked the redirection on Safari and it’s working but not on Chome. So it’s very likely that some local Chrome setting on my computer is causing the misbehaviour.
Hi, @Sujay. For that x-nf-request-id I think we have an explanation for why the redirect didn’t work. I’m showing this was the active deploy when that request was received:
Note what is says in the “Deploy summary” section at the top. Quoting:
If you do not get a 301 redirect locally when you use that command, would you please post the full output of that command here?
You can also direct message (DM) that information to us but I don’t think there will be any sensitive data and posting publicly will receive a faster reply than a DM will. I personally think publicly posting the command output is completely safe but please do what you think is best.
As always, if there are any other questions for us please share them anytime.
When I test the curl command you have mentioned, the redirect is working. But in Chrome the redirect doesn’t work whereas on Safari it does. So it’s certainly misbehaviour caused by a local setting on my individual Chrome browser. I am sending you the output of the curl request by DM but I am considering the problem as solved. Thanks for the time you and Chris invested to solve my problem.
@Sujay
Hi, I had the same problem lately and found this page.
The DNS behavior is correct, but it is not redirected in the browser by Serviceworker.
So I found that redirecting with Javascript in an html file then it works well.
I’m making SPA with vue-cli and vue/cli-plugin-pwa.
But this can be solved simply.
I add bellow code in the header of index.html.
@hyuta Thanks for your message. Luke and Chris’s answers helped me to solve the problem. But thanks anyways because it is always good to know that alternative approaches exist. Thank you very much for sharing learning from your experience.
Warm regards.