Laravel-admin 的路由无法添加 index.php 的伪静态吗?

Laravel-admin 的路由,如果最后一个是变量就会导致报错

$router->resource('/Settings/{type?}', SettingController::class);

网上的教程意思是需要把变量放前面。也就是

$router->resource('{type?}/Settings', SettingController::class);

这样是可行的。
然后我试着换了一下

$router->resource('/Settings/{type?}/index', SettingController::class);

是可行的。
但是

$router->resource('/Settings/{type?}/index.php', SettingController::class);

就报错404了。
这个原理是什么呢? 如果我就是想用这样的伪静态,需要用什么办法呢?

《L01 基础入门》
我们将带你从零开发一个项目并部署到线上,本课程教授 Web 开发中专业、实用的技能,如 Git 工作流、Laravel Mix 前端工作流等。
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
最佳答案

laravel的resource是不支持这样伪静态的,原因是.会被截取并识别为嵌套资源。

参考文档:嵌套资源.

1年前 评论
ISeee (楼主) 1年前
huozi1024 (作者) 1年前
ISeee (楼主) 1年前
讨论数量: 8
$router->resource('/Settings/{type?}/index\.php', SettingController::class);

这样试下,变量用问号基本都是在最后的吧

1年前 评论
ISeee (楼主) 1年前
ISeee (楼主) 1年前
deatil (作者) 1年前

laravel的resource是不支持这样伪静态的,原因是.会被截取并识别为嵌套资源。

参考文档:嵌套资源.

1年前 评论
ISeee (楼主) 1年前
huozi1024 (作者) 1年前
ISeee (楼主) 1年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!