This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

creg33270
creg33270

Hello, this is probably a simple thing but I don't know how to set a 410 status code for a page.

I have created a 410 page under Pages and defined a redirect for pages that no longer exist using .htaccess. When I look in the browser, however, the status code 200 is always transmitted when the page that no longer exists is called. Where and how (setStatusCode?) can I set the status code?

Thank you

creg33270
creg33270

I have found a possible solution - but I am not sure if it is okay.


function onStart()
{
    /**
     * Set the status code of the page to 410 (gone).
     */
    Event::listen('cms.page.display', function ($controller, $url, $page, $res)
    {
        $statusCode = 410;
        return Response::make($res, $statusCode);
    });
}

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.