404 |
On my page https://www.trzyksiezyce.pl I have default 404 page
Code: $routes->setDefaultNamespace('App\Controllers'); Which gives 404 status code on Bulk URL HTTP Status Code, Header & Redirect Checker | httpstatus.io https://httpstatus.io/ When I toggle to $routes->set404Override(function() {echo '404';}); or $routes->set404Override(function() {return view('404');}); It gives 200 status code How to fix it in codeigniter 4?
12-20-2021, 11:39 AM
(This post was last modified: 12-20-2021, 11:41 AM by captain-sensible. Edit Reason: extar )
a simple lateral thinking approach is to test via logic whether the page exists , i.e the view exits in views - thats the approach i've taken ,if the page can't be found i simply redirect to a custom page can't be found . have a look By typing something after the domain i have listed via CMS link.
I 'll make it easy go to this link : https://andrinadesignstudio.com/noPage My custom 404 is called nopage and thats what gets called if anything can't be found. For ultra nerds you can click on the music play while you read
Check status code of your 404 page here[url=https://httpstatus.io/][/url]
https://httpstatus.io/ It's 200 but should be 404. It's problem for indexing page in google. My https://www.trzyksiezyce.pl/sth page display default page 404 because codeigniter 4 custom 404 page gives wrong status code. And I am tring to solve this problem in forum
I use, I believe, a very simple solution:
PHP Code: $routes->set404Override(function() Where 'css' and 'title' correspond to variables used in the page header. PHP Code: <!DOCTYPE html>
If plan A fails, relax... the alphabet is 26 letters
But it should return HTTP 404 status code, check it. NOT HTTP 200 OK but HTTP 404.
My custom 404 page, which was made similar as yours and it returns HTTP 200 OK, so I am using now default 404 page (which returns HTTP 404) You can check it here https://httpstatus.io/
I solve the problem by replace file app/Views/errors/html/error_404.php
by my file. Is it proper way to display custom 404 page in codeigniter 4? I think the way PHP Code: $routes->set404Override(function() {return view('404');}); |
Welcome Guest, Not a member yet? Register Sign In |