默认laravel路由末尾不能加/,如果加了斜线会报404

要想支持url末尾的斜线需要在public/index.php加入如下代码:

$_SERVER['REQUEST_URI'] = trim($_SERVER['REQUEST_URI'], '/');

 

# 去除index action

if ($request_uri ~* index/?$)
{
    rewrite ^/(.*)/index/?$ /$1 permanent;
}

# 根据laravel规则进行url重写
if (!-e $request_filename)
{
    rewrite ^/(.*)(/)?$ /index.php?/$1 last;
    break;
}


error_page 500 502 503 504 /50x.html;
location = /50x.html {
    root html;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-15
  • 2022-12-23
  • 2022-02-25
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-01
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案