laravel 路由如何不区分大小写

陪伴而非守候
这个没啥好方法.
要嘛,你定义route使用的是pattern
参考这里http://stackoverflow.com/questions/21731151/laravel-case-insensitive-routes
要嘛,想ls说的,转换为小写.
处理这类(route)事情的正确文件是app/filters.php而不是server.php(更非入口文件).
App::before(function($request)
{
f u l l U r l = fullUrl= fullUrl=request->fullUrl();
if(preg_match(’@[A-Z]@’, f u l l U r l ) ) r e t u r n R e d i r e c t : : t o ( S t r : : l o w e r ( fullUrl)) returnRedirect::to(Str::lower( fullUrl))returnRedirect::to(Str::lower(fullUrl));
});
还有另一种方法,就是错误出现时,再进行大小写转换
这个得在app/start/global.php
App::error(function(Symfony\Component\HttpKernel\Exception\NotFoundHttpException e x c e p t i o n , exception, exception,code)
{
f u l l U r l = R e q u e s t : : f u l l U r l ( ) ; i f ( p r e g m a t c h ( ′ @ [ A − Z ] @ ′ , fullUrl=Request::fullUrl(); if(preg_match('@[A-Z]@', fullUrl=Request::fullUrl();if(pregmatch(@[AZ]@,fullUrl))
returnRedirect::to(Str::lower(KaTeX parse error: Expected 'EOF', got '}' at position 12: fullUrl)); }̲); 其实这两种方法都是下下策…host}:{KaTeX parse error: Expected 'EOF', got '}' at position 5: port}̲-t\"{public}“server.php”);

转自:
https://www.imooc.com/wenda/detail/527924

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值