How to create custom Error 404 page |
Hello, guys!
I'm creating a RESTful resource and I marked the page "new" as except. OK. Everything working nice, BUT, how to handle a custom Error 404 page in JSON format (the default is html) when someone access the /new path?
Hello Falko !
You can set a custom 404 page in the "app/Config/Routes.php" file: https://codeigniter4.github.io/userguide...l#override The part that will interest you is: PHP Code: // Would execute the show404 method of the App\Errors class So you just have to redirect to a Class::method of your choice, that will return the json response you are looking for :-) > Maybe the RESTful madman will have something to add ? :-D (02-02-2020, 05:24 PM)littlej Wrote: Hello Falko ! Thank you! It solved my question.
Perfect ! :-) If you have time, don't forget to rate my answer with the "Rate" button at the bottom ;-)
|
Welcome Guest, Not a member yet? Register Sign In |