How to Create Custom 403 and 404 Pages in Drupal

How to Create Custom 404 and 403 Pages in Drupal
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.

Author

  • Nick Savov

    Nick is the Director of Support at OSTraining and you can find him in almost every area of the site, from answering support requests and account questions to creating tutorials and software.

0 0 votes
Article Rating
Subscribe
Notify of
10 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Earl Miles
Earl Miles
8 years ago

The downside to this method is that by making it a node, it’ll show up using the basic search functions. That’s not always ideal. There’s a whole host of ways to resolve this, each with their own ups and downs.

John
John
5 years ago
Reply to  Nick Savov

Creating a special content type for default pages is a solution to that, as you probably have more than these two which you do not want to appear in searches or in administrative views.
So you have them easily at hand and not cluttering with the other content. If you do not want to have these shown in searches, you can go to the search view, and exclude these content types.

Johan
Johan
5 years ago
Reply to  Nick Savov

Additionally, the advantage of a special content type for such pages is that you can exclude these from sitemaps, configure metatags so that they are not indexed, etc.

NikLP
NikLP
8 years ago

This is very dated now, but I made a blog post about using custom error module, which is much more flexible and as Earl says doesn’t make nodes. This is from 2008, so do bear with me…
[url=http://www.kinetasystems.com/blog/creating-custom-error-pages-in-drupal]http://www.kinetasystems.co…[/url]

Douglas Beale
Douglas Beale
8 years ago

Thanks Nick! That is a nice feature, and I have used it, but if the Access Denied message is on , and it is triggered by an unauthorised user. You can’t do that. I really liked that String Override module to change the verbiage so something more friendly.

Anisha Shaikh
Anisha Shaikh
3 years ago
Reply to  Nick Savov

Thanks Nick  Can you help me memcache issue facing on my production site , I am not getting any help  from anywhere . Issue is after updating data , old data show on site and it keeps fluctuating with new content

10
0
Would love your thoughts, please comment.x
()
x