Bogus URL tries to use ErrorPresenter from bogus module which does not exist and results in 500 instead of 404
- josef.sabl
- Member | 153
Hi, I have problem with default routing and addresses like:
http://myweb.cz/humans.txt
These requests are generated by crawlers as they look for humans.txt file in the root (but this is only an example, other patterns appear as well, e.g. help.txt).
And the default router tries to route it to:
module: humans
presenter: txt
action: default
There is nothing like that and it wants to load ErrorPresenter from module Humans, which obviously does not exist. And it results in 500 Server Error. Correct reply would be 404 Not Found.
What to do about it?
UPDATE: Clarified question a bit.
Last edited by josef.sabl (2017-02-16 13:36)
- Pavel Kravčík
- Member | 1196
Default router (2.3, 2.4) show humans.txt if you put this file in root (www) correctly.
- josef.sabl
- Member | 153
Pavel Kravčík wrote:
Default router (2.3, 2.4) show humans.txt if you put this file in root (www) correctly.
So should I add all combinations of [a-z0–9]+\.[a-z0–9]{1,10} as files to my root? I don't think so ;-) humans.txt is of course only an example, robots can try anything.
- Pavel Kravčík
- Member | 1196
I guess I get it now. He doesnt want exception.
It's simple rewrite run()
func in
ErrorPresenter `with `$e->getCode();
- josef.sabl
- Member | 153
CZechBoY wrote:
I don't get what do want to achieve. Do you want load presenter
HumansPresenter
and fire actionactionTxt
or?
I want to return 404, not 500. Also I clarified the question a bit, I thought it was obvious, my bad…
Last edited by josef.sabl (2017-02-16 13:36)
- josef.sabl
- Member | 153
Pavel Kravčík wrote:
I guess I get it now. He doesnt want exception.
It's simple rewrite
run()
func inErrorPresenter `with `$e->getCode();
Unfortunately no. I would not need to do anything in ErrorPresenter. The error presenter would correctly return 404 code in the absence of, say, template. The problem here is, that default router tries ErrorPresenter from module Humans, which does not exist.