Open manja opened 5 years ago
This sounds like a correct behaviour, since no appropriate RequestHandlers could be found by the routing rules. I guess, you could create a generic all-inclusive rule and assign a RequestHandler implementation you'd like?
Yes, I created all-inclusive rule at the end of routes as a quick fix, so I ended up with 5 lines of code for a controller whose only function is to throw error. But that's not the solution IMHO.
While you may be correct that no appropriate RequestHandler was found - framework still throws 404 error. Which should be caught by RequestHandler::httpError and allowed to hook into. But no - it throws error directly, without any option to customize output. What if request was ajax and JSON was expected? Framework doesn't care - here's one line of plain text.
With this behaviour - we have two different use cases if 404 appears:
CMS handles this differently, and unified. If you try to access url which has neither page nor controller, CMS shows customizable 404 page just like in case sub-url failed to resolve. One thing (http 404) via two different ways to trigger, one same output. Customizable.
Affected Version
4.4.3
Description
When opening any route which is not defined inside SilverStripe\Control\Director:rules part of yml config file, HTTP 404 is thrown directly from Director, line 316, completely avoiding RequestHandler::httpError and all of its hooks.
Steps to Reproduce
Simply open any non-existing root url of framework only project, like /this-route-does-not-exist and you'll get No URL rule was matched error.