[Updated the post to be more brief]
We’re experiencing some redirect issues at our site, https://www.almex.com, both it and our dev branch deployments. The redirect rules were consistently the same and working since last year and issues showed up around mid-January.
I’d appreciate any comments about my fix as well as any insight to why the rules are behaving differently.
When the site tries to access any path starting at root, those requests are being rewritten as well, resulting understandably in 404’s. e.g. For reference our tech stack uses Gatsby for the site build. So attempts to load /page-data/northamerica/en/[someproduct]/page-data.json, redirect to /northamerica/en/page-data/northamerica/en/[someproduct]/page-data.json. This happens very often but not 100% of the time.
/* /northamerica/es/:splat 302 Country=ca,us Language=es /* /northamerica/en/:splat 302 Country=ca,us # Redirect customers for South Africa /* /southafrica/en/:splat 302 Country=ao,bw,cm,cg,cd,ke,mg,mw,mu,mz,na,za,tz,ug,zm,zw # Redirect customers for Asia Pacific /* /australia/en/:splat 302 Country=au,kh,ck,fj,pf,jp,kp,kr,la,my,mn,mm,nr,nc,nz,pg,ph,sg,sb,tw,th,vn [similar country rules removed for brevity, last rule follows] # Fallback redirect failing all of the above, countries not listed /* /northamerica/en/:splat 301
My interim fix:
I removed the wildcard/splat. A redirect still happens correctly at the root domain-only and prevents rewrites of root-based references. I have a temp deployment at https://604793130b8a77e853cfe7ac--almex-group.netlify.app/ with these changes:
/ /northamerica/es/ 302 Country=ca,us Language=es / /northamerica/en/ 302 Country=ca,us [etc...] / /northamerica/en/ 301
We lose the ability to have additional helpful redirects but at least the errors are prevented. I think my boss might be okay with that.
So I can understand why a wildcard could be causing those unexpected redirects but shouldn’t the rules only apply to external HTTP requests and not those originating from the same domain?
Were my rules set up incorrectly to begin with? Has there been a change in parsing behind the scenes? A combination of the two?