如何定义不区分大小写的(a 的一部分)路由?
例子:
在路由的固定部分使用大写字母不起作用:
我了解如何使用 ->with() 使 {parameter} 之类的参数使用正则表达式模式,但这对我处理路线的固定部分没有帮助,如上所述。
最佳答案
这可以通过以下方式定义路由来解决:
Route::get('/{userId}/{profile}')->with('profile', '(?i)profile(?-i)');
更聪明的是,将其定义为
pattern
,然后它也可以在路由组中使用。Route::pattern('profile', '(?i)profile(?-i)');
Route::get('/{userId}/{profile}');
关于regex - Laravel 不区分大小写的路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21731151/