One of our users didn't like the generic "Access denied" message for restricted pages. So we created this tutorial for him.
This tutorial will show you how to create custom error pages for 403 (Access Denied) and also 404 (Not Found) errors.
Step #1. Create the new error pages
First, let's create the content that we'll use for the new error pages.
- For example, go to Add content > Basic page.
- Create your page as usual. In this example, I'm creating a 404 error page. You can also create a 403 error page.
- We need to find the paths of our new error pages. You can look in the URL bar of your browser to find the paths:
Step #2. Add the custom pages to the Configuration
- Go to Configuration > Site information:
- Enter your new paths into the 403 and 404 error page boxes.
- Click "Save configuration".
Step #3. Test
Finally, test to make sure they work.
That's all there is to it. Congrats! Drupal makes it easy to add the custom 403 and 404 pages.
Note of caution
Because this approach uses nodes (i.e. individual pieces of content), the 403 and 404 pages will show in search results. Also, anything that ranks pages based on popularity would likely display at least the 404 page.
If either of the above are concerns for your site, consider using the CustomError module instead.