How do I define a case insensitive (part of a) route?
Example:
- Route::get('/{userId}/profile');
- http://domain.com/123/profile works fine.
Any use of uppercase in the fixed part of the route does not work:
- http://domain.com/123/Profile does not work
- http://domain.com/123/proFILE 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.
This can be solved by defining routes the following way:
Even smarter, define it as
pattern
, then it also becomes available in Route groups.For those using Apache you could also do this:
At this the top of your vhost file add
and in your .htaccess
Adding patterns only works on one route at a time, if you want all routes to be case insensitive add this to your /app/filter.php file in the before section:
I wrote a gist which does this: https://gist.github.com/samthomson/f670f9735d200773e543
Edit your app/filters.php to check for uppercase characters in the route and redirect them to a converted route.