Php 禁用'/';Silex路线
我需要禁用silex main routePhp 禁用'/';Silex路线,php,silex,Php,Silex,我需要禁用silex main route/,我的意思是,当您进入我的应用程序主页时,服务器必须以404响应。我是否可以更改有关路由的配置,以避免执行类似操作 代码 app->get('/', fucntion() use($app){ return new Response('Oops ... ', 404); }); 当我进入web应用程序时,在主路由中,服务器会这样响应我 错误 NotFoundHttpException in RouterListener.php line
/
,我的意思是,当您进入我的应用程序主页时,服务器必须以404响应。我是否可以更改有关路由的配置,以避免执行类似操作
代码
app->get('/', fucntion() use($app){
return new Response('Oops ... ', 404);
});
当我进入web应用程序时,在主路由中,服务器会这样响应我
错误
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
摘要
我可以禁用主路线吗?我可以禁用RouterListener以避免此类错误吗
谢谢。如果您不为
/
创建路由,silex将以404响应,就这么简单
您得到的是调试页面,因为您的应用程序正在调试模式下运行。关闭它,您将得到一个简单的404页面,没有信息泄漏。如果您不为
/
创建路由,silex将以404响应,就这么简单
您得到的是调试页面,因为您的应用程序正在调试模式下运行。关闭它,您将得到一个简单的404页面,没有信息泄漏。应用程序->获取('/',function()使用($app){语法错误->函数。应用程序->获取('/',function()使用($app){
语法错误->函数。