Welcome Guest, Not a member yet? Register   Sign In
Expansion of options: "Allowed URL Characters"
#1

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() {.
echo 
'Test;
}); 

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.
Reply
#2

You can customize the error page because it throws BadRequestException with the error code 400.

Create "error_400.php" in https://github.com/codeigniter4/CodeIgni...rrors/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/CodeIgni...hp#L76-L80
Reply
#3

If you want to change the HTTP status code, you need to create a Custom Exception Handler.
See https://codeigniter4.github.io/CodeIgnit...n-handlers
Reply




Theme © iAndrew 2016 - Forum software by © MyBB