Laravel case insensitive routes

后端 未结 3 1165
遥遥无期
遥遥无期 2021-01-12 16:28

How do I define a case insensitive (part of a) route?

Example:

  • Route::get(\'/{userId}/profile\');
  • http://domain.com/123/profi
3条回答
  •  花落未央
    2021-01-12 16:35

    This can be solved by defining routes the following way:

    Route::get('/{userId}/{profile}')->with('profile', '(?i)profile(?-i)');
    

    Even smarter, define it as pattern, then it also becomes available in Route groups.

    Route::pattern('profile', '(?i)profile(?-i)');
    Route::get('/{userId}/{profile}');
    

提交回复
热议问题