![]() |
Expansion of options: "Allowed URL Characters" - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29) +--- Thread: Expansion of options: "Allowed URL Characters" (/showthread.php?tid=90521) |
Expansion of options: "Allowed URL Characters" - Haliburton - 03-30-2024 With the introduction of URI Security, specifically the "Allowed URL Characters" option in CodeIgniter 4.4.7, I'm requesting to add an option that will allow a developer to specify a default page for an error (for disallowed characters) in production mode. I have tested: PHP Code: $routes->set404Override(function() {. and another test i.e. change: PHP Code: public ?string $override404 Unfortunately, if I enter a disallowed character in the address, only a default page is displayed: "Whoops! We seem to have hit a snag. Please try again later..." Which in my case is messy because of the bots that scan websites for what CMS or Framework the site uses. What this may also possess security implications, in case some bugs are found in the framework, and someone does not upgrade to the latest version in time. RE: Expansion of options: "Allowed URL Characters" - kenjis - 03-30-2024 You can customize the error page because it throws BadRequestException with the error code 400. Create "error_400.php" in https://github.com/codeigniter4/CodeIgniter4/tree/develop/app/Views/errors/html Note that if Excetions with the code 400 are thrown, the file is always used. So you must take care of production or development environments. See "error_404.php" https://github.com/codeigniter4/CodeIgniter4/blob/67fa536e201d1abf9e39278309d8ba76978608c9/app/Views/errors/html/error_404.php#L76-L80 RE: Expansion of options: "Allowed URL Characters" - kenjis - 03-30-2024 If you want to change the HTTP status code, you need to create a Custom Exception Handler. See https://codeigniter4.github.io/CodeIgniter4/general/errors.html#custom-exception-handlers |