我目前正在追踪路线。
$router->get('/contact-us','HomeController@contactUs')->name('contact-us');
$router->get('/about','HomeController@about')->name('about');
现在,我想使常规页面可按照以下路线访问:
$router->get('/{slug}','SomeController@about')->name('general-page');
但是主要的问题是与我们联系并且关于页面与子进程路由匹配并且调用了错误的控制器。有什么办法可以将这样的标签排除在一般的页面路由之外。
您可以在路线中添加一个模式,在其中排除条款contact-us
和about
,如下所示:
$router->get('/{slug}','SomeController@about')
->where('slug', '^((?!about|contact-us).)*$')
->name('general-page');
有关正则表达式的说明,请参见此处
这样,路由定义的顺序就不会产生任何影响。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句