0

When a 404 error is thrown in a project that uses Wagtail, I'd like to have the site redirect to a page in the CMS. How do I do this?

I know Wagtail has a redirects feature, but that doesn't seem to do what I want; if I were to use that I'd need to have some kind of wildcard selector that would be superseded by more specific redirects.

I searched around the issues but this was as close as I found. But that seems to be more related to admin 404s if I'm reading it right.

Brendan
  • 868
  • 1
  • 16
  • 38
  • Not sure, but the answer here might be helpful: https://stackoverflow.com/questions/56449188/having-a-404-for-each-site-in-a-wagtail-multisite-setup – Dan Swain Feb 27 '20 at 15:27
  • Don't redirect 404's. It will confuse visitors. Maybe customise the 404 template and display hints on how to proceed. You can display a link to the page you'd like the visitor to go. But replacing a 404 with a redirect is bad design. – allcaps Mar 01 '20 at 20:37
  • That ^ said, this is how you customise an error view https://docs.djangoproject.com/en/3.0/topics/http/views/#customizing-error-views – allcaps Mar 01 '20 at 20:40
  • @allcaps Maybe I'm missing something obvious (which is possible; backend dev is not my strength). How would I use `render404` to display a 404 page that was created in the CMS? Not sure how that would be possible without hardcoding some kind of reference. – Brendan Mar 02 '20 at 16:49
  • So you want to manage the contents of the 404 page in Wagtail? Since a 404 page is a single thing, you might use site settings. https://docs.wagtail.io/en/latest/reference/contrib/settings.html – allcaps Mar 08 '20 at 23:11

0 Answers0