Reputation: 732
I need to disable silex main route /
, I mean, when you enter in the main page of my application the server must response with 404. Can I change the configuration about routes, to avoid doing something like this.
Code
app->get('/', fucntion() use($app){
return new Response('Oops ... ', 404);
});
When I enter in the web app, in the main route the server response me something like this.
Error
NotFoundHttpException in RouterListener.php line 125:
No route found for "GET /" (from "http://localhost/projects/")
in RouterListener.php line 125
at RouterListener->onKernelRequest(object(GetResponseEvent), 'kernel.request', object(EventDispatcher))
at call_user_func(array(object(RouterListener), 'onKernelRequest'), object(GetResponseEvent), 'kernel.request', object(EventDispatcher)) in EventDispatcher.php line 174
at EventDispatcher->doDispatch(array(array(object(RouterListener), 'onKernelRequest'), array(object(MiddlewareListener), 'onKernelRequest')), 'kernel.request', object(GetResponseEvent)) in EventDispatcher.php line 43
at EventDispatcher->dispatch('kernel.request', object(GetResponseEvent)) in HttpKernel.php line 129
at HttpKernel->handleRaw(object(Request), '1') in HttpKernel.php line 68
at HttpKernel->handle(object(Request), '1', true) in Application.php line 496
at Application->handle(object(Request)) in Application.php line 477
at Application->run() in index.php line 8
Summary
Can I disable main route /
? Can I disable RouterListener to avoid this kind of errors?
Thanks you.
Upvotes: 0
Views: 261
Reputation: 34107
If you don't create a route for /
, silex will respond with a 404, simple as that.
What you get is the debug page, because your app is running in debug mode. Turn it off and you'll get a simple 404 page with no info leak.
Upvotes: 3