404 per domain?

Hi! I’m still trying to wrap my head around how to handle redirects properly. I have a multi-domain site, deployed from the same repo but different domains rewriting to different paths, like so:
https://www.lapoint.ch/* /de-ch/:splat 200

How do I utilize the /de-ch/404.html file that I’m building? All I’m getting is the built in netlify 404 page no matter what I seem to try.

Thanks.

Hey! Firstly I’d say take a look at deploy contexts and you might like to redirect by conditions (language and country), you can view those here: File-based configuration | Netlify Docs

Also, there is a nice guide on redirects here: [Support Guide] Making redirects work for you - troubleshooting and debugging that could come in handy!

In the instance above for your redirect I think you could do something like
/de-ch/* /de-ch/404 404
I think this should redirect any route that does not already exist to your 404 with a 404 error code.
I would still recommend looking at the links above and I personally find the syntax of netlify.toml redirect with conditions much nicer to understand.

IE:
Language redirect without netlify toml:
/* /de-ch/:splat 302 Language=de-ch

with netlify.toml
[[redirects]]
from = “/”
to = “/es”
status = 302
force = true
conditions = {Country = [“ES”]}

I have already tried what you suggest, i even tried /* to /de-ch/404.html, but I still only get the default 404 :frowning:

Den tis 3 nov. 2020 21:36Aaron via Netlify Community <netlify@discoursemail.com> skrev:

Does netlify tell you that X redirect rules have been processed when you build?
Is there a repo to see? :slight_smile:

I can’t share the repo but I can probably share the dist folder tomorrow.

Netlify processes all redirect rules successfully. I manage to rewrite by subdomain to subdirectory, but no other redirect/rewrite takes place.

This is so strange. Even if I have the following rules at the end:

# 404s
https://www.lapoint.ch/* /de-ch/404.html 404
/de-ch/*  /de-ch/404.html 404
/*  /de-ch/404.html 404

I still don’t get the 404.html page to show. I have verified the page does work if browsing to it directly:

Hoppla! Wir können diese Seite nicht finden! - 404 - Lapoint Surf camps ← works

https://www.lapoint.ch/demo gives

It feels like there’s a bug in the redirects system.

Do you have a public link to your most recent deploy?

Not sure what you mean by that. It’s deployed to https://www.lapoint.ch/ but maybe I’m misunderstanding your question.

If you go to netlify and view your deploys can you click on the latest one and send the URL. However, I think these are only able to be public if your repo is public too :lab_coat:

What I wanted to see is in your deploy details that is states the redirects have been processed? It would be much easier to debug with a public repo for a while but understand if you cant

image

edit:

I just loaded your site and see youre using React, could you not handle this via React Router?
and then set _redirects to be /* /index.html 200?

Client side can’t handle 404s no. The site is statically prerendered and then progressively turns into a dynamic client side application. 301s and 404s have to be handled on the server side of things.

The repo cannot be public I’m afraid, but here’s some info from the latest deploy:

_redirects file:

# ch redirect tests
https://www.lapoint.ch/blogg/surf-addiction-is-not-curable/ https://www.lapoint.ch/blog 301

# Redirects from what the browser requests to what we serve
https://www.lapoint.dk/*  /da-dk/:splat 200
https://www.lapoint.ch/*  /de-ch/:splat 200
https://www.lapoint.de/*  /de-de/:splat 200
https://www.lapointcamps.com/*  /en-us/:splat 200
https://www.lapoint.no/*  /nb-no/:splat 200
https://www.lapoint.se/*  /sv-se/:splat 200

# 404s
https://www.lapoint.ch/* /de-ch/404.html 404
/de-ch/*  /de-ch/404.html 404
/*  /de-ch/404.html 404

Note, the non-.ch domains have not been transferred to netlify as of yet, since the service isn’t working as expected. Yet.

1 Like

EDIT: My previous reply was wrong:

View this: Redirect options | Netlify Docs
I would make sure you add ! to the end of your redirect rules and make sure all the domains are added to the site.

Suggestions below from previous edit:

Im out at the moment but an idea could be to have a main domain that would then redirect to your https://www.lapoint.dk/.se/.no domains dependent on the country code. Such as:
/* https://www.lapoint.dk/:splat 302 Language=de-ch (I don’t know the codes so dk and de-ch might not make sense but you get the point?).

OR
You could have one route domain for good and only change your language based on country code?
lets say you choose .dk as your domain so it is https://www.lapoint.dk then you could do
/* /de-ch/:splat 302 Language=de-ch
when the language is set to de-ch it will route everything through /de-ch first?

I appreciate you trying to help, but I’m not doing redirects from absolute domains. I’m doing rewrites and THOSE work, and are according to documentation.

How would you otherwise have different domains for different languages in the same site?

For which rule do you I should add the ! ?

Hey, I’ll tag in @Scott who might be able to give more details.

One extra thing I’ll note is that when you’re doing your redirects to /de-ch/404.html 404, that file needs to actually exist as that’s not a rewrite that will be trying to find the 404 files in that location.

Hopefully, you’ll get this sorted soon!

The file exists :slight_smile:

Den tors 5 nov. 2020 19:41Aaron via Netlify Community <netlify@discoursemail.com> skrev:

Two things to try:

Firstly, can you deploy the 404.html to /de-ch/de-ch/404.html? We have an inkling that this is where the proxy is looking and this would be a quick way to check!

Secondly, can you try re-arranging your redirects file so that a suitable 404 appears above the 200 rule? This is a suspicion because I don’t believe the 404 is being read after the proxy (200) rule is met in the file.

Eager to see if either help!

N.B. I posted the same response in our Helpdesk ticket – happy to continue the conversation in either/both location(s)!

1 Like

I think it makes sense, for posterity, to continue here then :slight_smile:

I first try deploying with /de-ch/de-ch/404.html added but nothing else changed. That did not solve the issue, still only seeing the default 404 page.

I then tried setting the 404s above the 200s rules. Then I see our custom 404, but of course, this stops the redirects from processing since we hit a static file (404.html), so no domain rewrites are in effect and basically the whole site is then down. Had to revert that change immediately because this is a live site.

@Scott This is frankly getting a bit frustrating. The way it seems now it it seems it is not possible to have domain rewrites + custom 404, which frankly is a dealbreaker. We are paying customers and I was expecting this to work or at least to be rectified when one finds these things.

Right now we have migrated just one out of six domains for our site to Netlify, and it seems we cannot go on with the rest? Our client is waiting for this work to be finished.

Cool, the first test failing is okay. The second test passing is fine.

For the 200 rules, can you now attempt to force them with a 200! please?

Same behaviour. If 404 rule comes first, 200! rule won’t apply, if 200! rule comes first, 404 rule won’t apply.

@Scott I tried the two following _redirects setups

# ch redirect tests
https://www.lapoint.ch/blogg/surf-addiction-is-not-curable/ https://www.lapoint.ch/blog 301

# Redirects from what the browser requests to what we serve
https://www.lapoint.ch/*  /de-ch/:splat 200!
https://www.lapoint.dk/*  /da-dk/:splat 200
https://www.lapoint.de/*  /de-de/:splat 200
https://www.lapointcamps.com/*  /en-us/:splat 200
https://www.lapoint.no/*  /nb-no/:splat 200
https://www.lapoint.se/*  /sv-se/:splat 200

# 404s
https://www.lapoint.ch/* /de-ch/404.html 404
/de-ch/*  /de-ch/404.html 404
/*  /de-ch/404.html 404

And

# ch redirect tests
https://www.lapoint.ch/blogg/surf-addiction-is-not-curable/ https://www.lapoint.ch/blog 301

# 404s
https://www.lapoint.ch/* /de-ch/404.html 404
/de-ch/*  /de-ch/404.html 404
/*  /de-ch/404.html 404

# Redirects from what the browser requests to what we serve
https://www.lapoint.ch/*  /de-ch/:splat 200!
https://www.lapoint.dk/*  /da-dk/:splat 200
https://www.lapoint.de/*  /de-de/:splat 200
https://www.lapointcamps.com/*  /en-us/:splat 200
https://www.lapoint.no/*  /nb-no/:splat 200
https://www.lapoint.se/*  /sv-se/:splat 200

All rules process fine. Neither version serves our custom 404 when it should.