Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Error pages not working


Go to End


4 Posts   1001 Views

Avatar
icp

Community Member, 3 Posts

24 August 2016 at 1:12am

Edited: 24/08/2016 9:55am

Hi,

I have created a custom 404-Error page. If a user requests a non-existing page this error page is indeed delivered. But the Respons-Status is 200 instead of 404.
But this yields problems with search engines, because they need the 404-response in order to delete the page. How can I change this behaviour?

Sorry, forgotten: I'm using version 3.3.

Ralph

Avatar
icp

Community Member, 3 Posts

12 September 2016 at 7:48am

Does nobody have an idea?

Avatar
ZarockNZ

Community Member, 17 Posts

18 October 2016 at 10:47am

Hi,

In the index() function of the page controller, try setting the status of the response to 404. You will also need to return an empty array so the page renders (unless you already have an index function returning some data for use in the template).

public function index()
{
    $this->getResponse()->setStatusCode(404);
    return array();
}

Avatar
icp

Community Member, 3 Posts

19 October 2016 at 6:14am

Hi,

thanks for your answer! Unfortunately this does not work for me. The Apache still returns statuscode 200:-(