Django - The Easy Way Django - The Easy Way
Samuli Natri 2016.10.11
Samuli Natri is a software developer who enjoys programming games and web applications. He attended Helsinki University Of Technology (Computer Science) and Helsinki University (Social Sciences).

Drupal 8 - How To Disable Access To Single Nodes With Rabbit Hole Module

Tutorial on how to control access to the /node/[nid] page.

Use Case

You have a view that lists articles but you want to disable access to single articles in node/[nid].


drush -y en rabbit_hole

How To Use It

Go to admin/modules and enable the entity types you want to restrict access to:

Go to admin/structure/types/manage/article and you can find the Rabbit Hole settings at the bottom.

Select Access denied as the behavior:

Now you can see the articles listed in the front page:

But if you click them, you get access denied:


Go to /admin/structure/types/manage/article

You can also choose Page not found behavior or make a Page redirect:

Install Token module to see the token widget in the image.

In this case you would be redirected to the login page whenever you try to access an article in node/[nid].

Overrides And Permissions

You can allow these settings to be overridden for single entities in /admin/structure/types/manage/article:

Edit any article and you have the option to change the behavior for that single entity:

You can also allow certain roles to bypass Rabbit Hole in /admin/people/permissions: