S
S
Stanislav Fateev2013-12-11 16:16:11
PHP
Stanislav Fateev, 2013-12-11 16:16:11

How to make a custom 404 page return the correct code?

The site runs on nginx+php-fpm+cakephp - custom 404 page gives 200 OK, how to make it give the correct code? How can I check what the problem is, in the nginx settings, php-fpm or cakephp code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniel Mukhametshin, 2013-12-11
@SpaceBike

To be honest, I have not studied CakePHP, but if you look at how 404 errors are excluded there

public function view($id) {
    $post = $this->Post->findById($id);
    if (!$post) {
        throw new NotFoundException('Could not find that post');
    }
    $this->set('post', $post);
}

Then you need to find the NotFoundException class, look at the parent and already in the parent look at the catch block
PS If anything, then you need to send a header header("HTTP/1.0 404 Not Found")or for Fast-CGIheader("Status:404 Not Found")

K
Konstantin, 2013-12-11
@evil_random

This should be done by nginx

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question