【发布时间】:2018-10-04 16:07:53
【问题描述】:
任何帮助为什么这不起作用,我使用的是 Laravel 5.4 版本,这是我的路线
app\Providers\RouteServiceProvider.php
public function map()
{
$this->mapWebRoutes();
$this->mapExampleRoutes();
}
protected function mapExampleRoutes()
{
Route::prefix('example')
->middleware('example')
->namespace($this->namespace.'\\Examle')
->group(base_path('routes/example.php'));
}
路由\example.php
Route::get('/{any}', function () {
return view('example.app');
})->where('any', '.*');
$ php artisan route:list
+--------+-----------+-----------------+------+----------+-------------+
| Domain | Method | URI | Name | Action | Middleware |
+--------+-----------+-----------------+------+----------+-------------+
| | GET|HEAD | / | | Closure | web |
| | GET|HEAD | example/{any} | | Closure | example |
+--------+-----------+-----------------+------+----------+-------------+
问题是当我尝试访问 /example 它返回 not found (NotFoundHttpException) ,
其他路由正在运行,例如 /example/login 。
知道为什么这个不起作用吗?
【问题讨论】:
-
你的 routes.php 看起来怎么样?你确定 example.php 包括在内吗?
-
感谢添加评论。看看[RouteServiceProvider.php]。在这个文件中包含 [routes/example.php]。 ~Laravel 5.3版本升级,添加app/Providers/RouteServiceProvider.php并包含路由文件(routes/web.php和routes/api.php)
-
如果我的写作不是为了回答你的问题,我很抱歉:(