我从拉里开始,我需要做一些像localhost/diretory1/directory2/directory3这样的事情
是否有可能像嵌套路由一样设置这个位置?目前它的工作方式类似于localhost/directory1 -> localhost/directory2
发布于 2014-11-07 10:49:04
所以你可以做的是定义一个弹状体路径来捕捉所有的请求。(请确保在该一条路由之上定义其他路由,以便如果没有其他匹配的路径,则请求只在段塞路由中结束)
Route::any('{slug}', function($slug){
$directories = explode('/', $slug);
// lookup the directory(ies) in the db, file system, etc
if(!$exists){
// when the directories don't exists, it's probably appropriate to throw a 404 Not found error.
App::abort(404);
}
}在路由函数中所做的事情(或者一个控制器,如果它得到太多的代码而不能驻留在routes.php中)取决于您。我不知道你的应用程序是如何工作的,所以我帮不了你。
https://stackoverflow.com/questions/26787244
复制相似问题