Configure custom error pages in multisite or multilingual environment

Use this article to configure handling custom errors using Sitefinity CMS pages, where each site or each language has its own version of the custom error page.

IMPORTANT: The instructions provided below require you to put an MVC or WebForms widget, respectively,  that sets the status code to 404. Otherwise you might compromise your website SEO ranking. For more information see Use a Sitefinity CMS MVC page as a custom error page and Use a Sitefinity CMS WebForms page as a custom error page.

Multisite mode 

When managing more than one website in your Sitefinity CMS project (Multisite), you can have a different custom error page for each site. This enables you to modify the custom error page according to the specific website needs, for example apply different design.

As long as each of your websites has a custom error page with a URL matching the one you have specified when configuring your custom errors in the web.config, Sitefinity CMS will serve the proper page for the corresponding site. For more information see: Custom error pages.

For example, if you have 2 sites - https://myfirstsite.com, and https://mysecondsite.com, and each of them contains a custom errors page with a URL https://myfirstsite.com/404 and respectively https://mysecondsite.com/404, and your custom errors have been configured to handle the 404 status code by serving a page with URL /404, then as long as users browsing https://myfirstsite.com encounter a resource not found (404) error, https://myfirstsite.com/404 error page will be served, and the ones, who encounter a 404 error on https://mysecondsite.com will get the https://mysecondsite.com/404 page served. 

Multilingual mode 

If your site has more than one languages defined, you might want to offer users a friendly custom errors page for the current language version of the site. To achieve this you must introduce different custom errors configurations in your we.config using the <location> tag. The <location> tag enables you to specify different configuration behavior for different sections of your website. By default, Sitefinity CMS uses a prefix (directory) to resolve each language for the site. For example, the Bulgarian language version of the content will be served on https://mysite.com/bg/. You can use the language prefix to specify the path for the <location> tag, and thus have the configuration inside apply only for the /bg/ path. The following sample demonstrates the above described configuration:

For more information on configuring <location> tags in your web.config, see: MSDN: How to: Configure Specific Directories Using Location Settings.

NOTE: If your website is using different domains (for example, https://bg.mysite.com and https://us.mysite.com) to serve multilingual content, you do not need to follow the approach for configuring a <location> tag, described above. You can have one configuration for custom errors in your web.config, and different translations of your custom error pages for each language. As long as the URLs of your custom error pages match in each language,  the proper page will be served for the current language domain users are browsing. This is because the specified paths are relative and are always resolved for the current domain. For more information about configuring how the multilingual URLs behave, see: Language settings.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?