![]() |
Status codes do not match, help to understand this. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Status codes do not match, help to understand this. (/showthread.php?tid=74427) |
Status codes do not match, help to understand this. - Digital_Wolf - 09-22-2019 Good day! I had a question: I noticed that when going to a non-existent page, I was thrown to the one that is set in "$routes->set404Override();" and it's right, but in the http response when using the method "$this->response->getStatusCode()" on the screen displays an error "200" what is logically not true, it should be ? RE: Status codes do not match, help to understand this. - kilishan - 09-23-2019 If the controller set to override a 404 is catching it, then it's not a 404 code until that controller says it is. The intention here is that it gives you chance to perform any other actions when a page cannot be found. This might be as simple as a 404 page, or one that provides suggestions for pages they might have been looking for, or even the ability to map URI's to files that represent a valid HTML page. You can be pretty creative with it's uses here. In all 3 of those examples, it returns a valid page so 404 is not valid. It's up to your override controller to determine the status code to present. RE: Status codes do not match, help to understand this. - Digital_Wolf - 09-23-2019 Thank you for clarification ! As I understand it, the error page, you need to develop yourself, for example "ErrorsController.php" in which when you use the class "Response" can be mapped to status codes with the methods, or all the same it is done a little differently ?! |