Prevent access to child pages

I’d like to use child pages as additional “data sources” to structure my content, e.g you’ve a gallery page and the child pages work as albums. The thing is, I don’t want these child pages to be accessible by URLs, I just want to use them to include in the gallery page. How do I prevent the user to access them or even worse google bot may index them.

I’m scared… :face_with_head_bandage:

You can use a route to reroute these pages to the parent.

With the route in place, these pages are not accessible by users and Google will not index these pages, either.

c::set('routes', array(
    'pattern' => 'parent-uid/(:any)', // assuming the parent is a first level page
    'action'  => function() {
       return go('parent-uid', 404);
1 Like