---
title: "How to Control Access to Restricted Pages with the Rabbit Hole Module in Drupal 8"
description: "The Rabbit hole module for Drupal 8 (also compatible with Drupal 9!) is a very popular Drupal module that enables you to restrict access to certain pages. Read more about how you can implement it."
url: https://www.specbee.com/blogs/control-access-to-restricted-pages-with-rabbit-hole-module-drupal-8
type: Article
author: "Shruthi Shetty"
categories: "Code Corner"
published: 2021-04-20
updated: 2026-09-28
---

# How to Control Access to Restricted Pages with the Rabbit Hole Module in Drupal 8

There might be instances when you want to restrict access to some pages of your website. It could because you want increased [security](https://www.specbee.com/blogs/drupal-security-strategies-and-top-drupal-9-security-modules) for the high-risk data that’s lying on the page or you want only your subscribed users to be able to view the content. This functionality is provided in Drupal 8 by a module with an interesting name called the Rabbit hole module. The module is also compatible with [Drupal 9](https://www.specbee.com/services/drupal-web-development)! In this article we will be elaborating on the module and how you can implement it in your next Drupal project.

 ![Control Access to Restricted Pages](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Control_access_restricted_pages_0.jpg.avif?itok=whZ4CalG)

 

 ## What does the Rabbit Hole module do?

The Rabbit Hole module provides the ability to control what should happen when an entity is being viewed at its own page. It also controls what happens when someone visits an entity page.

In simple it allows you to easily redirect or prevent users from viewing specific types of entities on your site. You can grant or deny [user access](https://www.specbee.com/blogs/user-roles-and-permissions-your-drupal-website-best-practices) to entity types or specific Drupal entities based on user roles. For example: To display paid content to users with a subscription or to allow special user roles.

Some of the entities that it supports are Nodes, Taxonomy Terms, Users, Files, Group and Media Entity

The Rabbit hole module for Drupal 8 provides multiple options to restrict access to specified pages. You can choose to deliver access denied or page not found pages. You can also choose to redirect a page to any path/URL. Or you could choose to display the entity as it is.

## Configuring the Rabbit hole module

Here’s how you can configure the Rabbit hole module for an entity type:

- Download the module using
    
    ```plaintext
    composer require drupal/rabbit hole
    ```
- Click on **Extend** in the Admin toolbar.
- Scroll down and select the entities for which you want to add the functionality for
- Click on **install**.

 ![Configuring the Rabbit Hole Module](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Rabbit_hole_module_0.png.avif?itok=YeA5VoYz)

 

 *Configuring the Rabbit hole module: Select the required entities*

### Create a VIP Role

When you create a VIP role, only paid users will be allowed to view the content. Without a paid membership user will be Authenticated user.

- On the Admin toolbar click on **People -> Roles -> Add Role**
- Give the role name as VIP
- Click on Save

 ![Creating VIP Role](https://www.specbee.com/sites/default/files/styles/large/public/migrated/VIP_role_0.png.avif?itok=7aUB033P)

 

 *Creating VIP roles*

### Create Users

Here let’s create an Authenticated user and a VIP user.

- Click on **People -> Add user**
- Enter the data and select the role as **VIP**
- Click on Create a new account

 ![Create New User Account](https://www.specbee.com/sites/default/files/styles/large/public/migrated/New_user_account_0.png.avif?itok=shltQ5gq)

 

 *Create a new user account*

In the same way create another user with the role of Authenticated. After that, the People page will look like this.

 ![All Users](https://www.specbee.com/sites/default/files/styles/large/public/migrated/All_users_0.png.avif?itok=DK4DslAT)

 

 *All Users*

### Create VIP Content Type

- Click on **Structure -> Content type -> Add content type**
- Give a proper name and description for the content type
- Click on Rabbit hole Settings
- Keep “Allow these settings to be overridden for individual entities” option as checked. It will allow administering permissions on a node basis
- Choose the redirect option and enter the URL of the site to which you want to redirect
- Click on **Save and manage Fields**.

 ![Create VIP Content Type](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Create_VIP_content_type_0.png.avif?itok=d92hZreI)

 

 *Create VIP Content Type*

- Add an image field and place it above the body field on the content type to manage display settings.
- Click on Save

 ![Save VIP](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Save_VIP_0.png.avif?itok=RxDUaC3J)

 

 ### Set Access Permissions

Users with a VIP role will have to be able to bypass the Rabbit Hole control.

- Click on **People - > Roles**
- Click on the dropdown arrow of VIP role and click on **Edit permissions**
- Search and Check for the **Bypass Rabbit hole action for Content** permission. Save the permissions.

 ![Bypass Rabbit Hole](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Bypass_rabbit_hole_0.png.avif?itok=JU5sGjXE)

 

 ### Create Content

- Click on **Content -> Add content -> VIP content**
- Create a node and hit **Save**

 ![Create Content](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Create_content_0.png.avif?itok=Usvmqyzq)

 

 *Create content*

### Test the Rabbit hole Module

- Login as an Authenticated User
- Click on the Teaser title of the VIP content on the Home page)

 ![Testing Rabbit Hole](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Testing_rabbit_hole_0.png.avif?itok=ezlRQNeq)

 

 *Testing the Rabbit hole module*

- It will (and should) redirect to the Access denied page.

 ![Access Denied for Authorized User](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Access_denied_0.png.avif?itok=sZlZbNOq)

 

 *Access denied for an Authenticated user*

- Now let’s logout and login again but this time as a VIP user.

 ![Login VIP User](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Login_Vip_User_0.png.avif?itok=Rbo4MGd5)

 

 - Go to home page and click on the Teaser title.

 ![Committed to Safety](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Committed_Safety_0.png.avif?itok=JXE_9Dvd)

 

  ![View Node and Content](https://www.specbee.com/sites/default/files/styles/large/public/migrated/Node_content_0.png.avif?itok=7U8Fn8Q0)

 

 - As a VIP user, you will now be able to see the node and content.

The Rabbit hole module for Drupal 8 offers a great deal of flexibility to enable granular access control to entities. And it is also compatible with Drupal 9! It is one of the most popular [Drupal modules](https://www.specbee.com/blogs/top-drupal-9-modules-for-your-drupal-project) having more than 40k installs. Looking for assistance in leveraging and customizing Drupal modules like this one? Our [Drupal development team](https://www.specbee.com/services/drupal-web-development) would love to talk to you!