DNN Evoq can display custom 404 error messages when visitors navigate to an invalid page. This is done via settings changes in IIS and DNN, as well as a small change to the web.config file.
- Access to the DNN file structure and server.
- Access to an Administrator or Super User account.
When browsing for a resource such as a .txt or .asp that does not exist you will receive the static 404 or 404.0 page. Note this also will fix receiving the static page for searching /bin or /web.config
- Ensure that your install of IIS has the HTTP Errors module. This can be added via Windows Features, under Internet Information Services > World Wide Web Services > Common HTTP Features. Ensure that HTTP Errors is checked, then hit OK.
- Inside of the web.config file in your DNN root directory, you will need to find the <system.webServer> tag.
- Add the following inside of the tag:
<httpErrors errorMode="Custom">In the path attribute, you can set the absolute URL of the custom error page that you will be redirecting your users to.
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="500" prefixLanguageFilePath="" path="INSERT_YOUR_URL_HERE" responseMode="Redirect" />
<error statusCode="404" path="INSERT_YOUR_URL_HERE" responseMode="Redirect" />
- If an httpErrors block already exists in the code, you may need to examine its current functionality to determine whether it needs to be overwritten or merely appended.
- Log into your DNN instance and navigate to Settings > Site Settings > Site Behavior. Ensure that the 404 Error Page is set to your desired custom 404 page.
Before testing any changes, it may be helpful to restart the site via IIS. As with any testing where browser cache may cause problems, tests should be done in an incognito or hidden browsing mode with cache disabled. To test that the user is correctly redirected to the correct error page:
- Go to any page that does not currently exist for your site. You should be able to see the custom error page.
- If correctly configured, this should work for non-website file extensions as well, such as https://mywebsite.com/NotARealFile.txt