Route parent pages to 404 error

Hi all, I am just wondering what would be the best way to route a parent page that doesn’t contain any content to just show like there was no page there at all (like a 404).

Essentially I have created a parent/child structure so that the URLs are formed the way I want “services/design”, “services/construction” for example. I was thinking of using a route to the error page but this seems to change the url from “services” to error, which is not exactly like an error page as when I put in a URL of a page that doesn’t exist it keeps the URL in the address bar, rather than “error”.

Any help is greatly appreciated!

Instead of redirecting to the error page, return it:

            'pattern' => 'your-pattern',
            'action' => function () {
                return page('error');

Thank you, that’s worked perfectly!