Native 40x error redirect instead of rendering


we’re using the native 40x error handling from this release note. This configuration just renders the 404 page in the currently not found page. But I want to archive that the user will be redirected to the real 404 page. Is that possible?

I would appreciate it if somebody can help me with this problem. :slight_smile:

Could help code from the " " ?

Thanks for your answer Christoph, but this is the same code from the release nodes (the link that I mentioned yesterday). The Neos.Fusion:Renderer just renders the 404 page into the current one and that’s not what I want. I need a real redirect to the 404 page.

Imagine the following: you visit the not existing page and currently Neos stays on this URL and renders the 404 content into it. But I need a redirect to

I hope this explains better my problem.

Any specific reason why you want to do that?
Usually it’s more helpful for tracking and other things to know which page they tried to access.

But besides that instead of rendering another document you can also render a Neos.Fusion:Http.Message with a redirect header.

Because we have a frontend login and therefor protected pages. If you are not logged in and try to access a protected page you will get a 404 notification. For this specific behaviour our marketing wants a redirect to the login page.

I have to archive that the standard 404 errors act like before. But 404 errors of protected pages have to be redirected to the login page.

After hours of Google research, this is my current configuration:

prototype(My.Website:ProtectedRedirect) < prototype(Neos.Fusion:Http.Message) {
    httpResponseHead {
        statusCode = 301
        headers.Location = Neos.Neos:NodeUri {
            node = ${q(site).find('#f1d86dfe-2dcc-4464-a096-c44939c5a0b0').get(0)}
            absolute = true

error {
    protected {
        @position = 'start'
        condition = ${q(node).is('[instanceof My.Website:ProtectedPage]') && statusCode >= 400 && statusCode < 500}
        renderer = My.Website:ProtectedRedirect
    4xx {
        @position = 'end'
        @context.notFoundDocument = ${q(site).find('#47bd578a-0a26-4360-8f49-e799187b32ab').get(0)}
        condition = ${statusCode >= 400 && statusCode < 500 && notFoundDocument}
        renderer = Neos.Fusion:Renderer {
            @context {
                site = ${notFoundDocument.context.currentSiteNode}
                node = ${notFoundDocument}
                documentNode = ${notFoundDocument}
            renderPath = '/root'

Unfortunately this does not work, it acts every time like a normal 404 (page not found) error. I think that the part of the condition that checks the instance does not work, because the page (node) object is never present.

The next error is that the «My.Website:ProtectedRedirect» is not working. If I use this configuration…

error {
    4xx {
        @position = 'start'
        condition = ${statusCode >= 400 && statusCode < 500}
        renderer = My.Website:ProtectedRedirect

…my browser says that the page could not be found (see attached screenshot).

Screenshot 2020-03-12 at 09.31.15

Yes Fusion cannot see the page if it is protected via a privilege.
Therefore you cannot access its properties or nodetype.

The topic was discussed a few times in Slack and here, but I’m not sure if there was a simple solution.
You can still show the login on the 404 page.

Unfortunately this is not a solution because the user should not see the login screen every time he entered a wrong URL. Only if he tries to access a protected page without being logged in.

You could keep some kind of protected list of pages with their urls in a persistent cache that gets updated when a document node is updated. And you verify the url in the 404 handler.
Nothing else comes to my mind right now, sorry.

Puh ok, this is a little bit beyond my skills. I know that this is maybe too much to ask but can you show me how to archive this?