Custom error pages
In order to create a custom 404 page you must add an additional route for this page. When you have this route, the page is displayed instead of the default 404 page.
Configure settings
- In Sitefinity CMS backend, navigate to Administration » Settings » Advanced » Pages » Custom Error Pages » Error Types » 404.
- Check the Redirect option.
This ensures that 404 requests are routed through the route for the custom page and are cached according to the cache settings.
Create the routing
To create a 404 page, first create the route and then add a page.tsx file for that route.
- Navigate to // src/app/404/page.tsx.
-
Use the following sample to create the route.
Configure the cache settings for this route in production by setting dynamic to force-static and specifying the revalidate time to your preferred interval. For more information about cache settings, see Configure cache.
export const dynamic = 'force-static';
export const revalidate = 600;
In development mode, you can skip caching to immediately see changes while editing the page.