How do I define a case insensitive (part of a) route?
Example:
Any use of uppercase in the fixed part of the route does not work:
I understand how I can make parameters like {parameter} use a regex pattern using ->with(), but that does not help me with the fixed part of the route, like described above.
on Jul 27, 2020. The standard is that the path in a URL is case-sensitive. If you want to make case-insensitive paths work, I might look into using custom routes and redirect everything to a lower-case path.
Laravel Routing Case-insensitive routeswill match a GET request to /login but will not match a GET request to /Login . In order to make your routes case-insensitive, you need to create a new validator class that will match requested URLs against defined routes.
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}');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With