我有以下路线:
Route::get(
'{slug}-lawyer-in-nepal',
array(
'as' => 'practise-area.detail',
'uses' => 'PractiseAreaController@detail'
)
);
当子弹不包含“-”时有效,但是当弹头包含404时抛出404。有什么解决办法吗?
答案 0 :(得分:3)
使用Regex指定子弹的格式可能会在路由器解析您的网址时提供帮助。
routes / web.php
Route::get('{slug}-lawyer-in-nepal', [
'as' => 'practise-area.detail',
'uses' => 'PractiseAreaController@detail'
])->where('slug', '[\w-]{1,}[^-]');
您可以查看Laravel Routing - Regular Expression Constraints documentation,了解更多信息。