I am trying to accomplish a seemingly simple task: get one of our subdomains, when accessed directly, to just redirect to a single page on the website. However, I seem to have tried just about every possible permutation of doing that in the _redirects file and it breaks. Site is ecfs.netlify.app
The rules attempted:
https://subdomain.domain.org https://www.domain.org/en/page 301! → Loads of CORS errors in console, page blank, although it appears that the redirect is “working”
https://subdomain.domain.org /en/page 301! → Breaks entirely with a react error
https://subdomain.domain.org https://www.domain.org/en/page 200 → Redirect seems to fail, just goes to main catch-all homepage
It seems to be that this should be fairly simple, and looking at other forum questions it seems like I’ve tried things that have worked for folks, so not entirely sure what (probably obvious) thing I’m missing!
Hi, @ECFScommunications. I’m on the Netlify support team so I’m able to see the site and redirects you are talking about.
The good news is you are doing it correctly. The bad news is that I can reproduce the error but only using a web browser. If I test with
curl for example, I get a 301. With a browser I see the 200 instead of the redirect.
Would you please keep the existing rules in
_redirects unchanged (as they are correct) but trigger a new deploy to clear the site cache?
Hey Luke, thanks for checking!
I just cleared the site and redeployed, but I seem to continue to run into the same issues. If you look at our _redirects file you can see that I even have a few different examples/iterations of how to do it, but they all seem to break.
https://families.ecfs.org/* https://www.ecfs.org/en/families 301!
breaks with a bunch of CORS policy errors in the console, and the page is blank. When I tried with a 200 redirect, nothing seemed to happen.
Appreciate your further help!
The 200 doesn’t redirect, it returns the content from the endpoint without changing the URL seen in the address bar.
https://families.ecfs.org/fonts/InterUI-Regular.woff2 does trigger the redirect to
I am thinking the
Link header preloads with relative pathnames is (part of) the culprit. Looking at
curl -IL https://families.ecfs.org/page-data/app-data.json, there is no
Link header on the original request, so there are no preloads. Only once redirected to
https://www.ecfs.org/en/families does the
Link header appear. Whereas looking at
curl -IL https://families.ecfs.org/ the
Link header is present at the beginning.
While possibly not an ideal solution for you, setting up a separate site with little more than a
_redirects file for the sub-domains may work in this instance (rather than having them connected to the main site.)