陪伴而非守候
这个没啥好方法.
要嘛,你定义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(′@[A−Z]@′,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”);
laravel 路由如何不区分大小写
最新推荐文章于 2022-08-18 15:02:10 发布