Laravel路由匹配前缀后的所有内容
我正在尝试匹配URL中的路径,如下所示 我的HTTP请求Laravel路由匹配前缀后的所有内容,laravel,laravel-4,laravel-5,laravel-routing,Laravel,Laravel 4,Laravel 5,Laravel Routing,我正在尝试匹配URL中的路径,如下所示 我的HTTP请求 http://localhost/myprefix/extra/x/x/x/x/x/2/3/2/ routes.php Route::group( ['prefix' => 'myprefix'], function () { Route::get('extra/{path}', ['as' => 'myprefix.one', 'uses' => 'MyController@index
http://localhost/myprefix/extra/x/x/x/x/x/2/3/2/
routes.php
Route::group(
['prefix' => 'myprefix'],
function () {
Route::get('extra/{path}', ['as' => 'myprefix.one', 'uses' => 'MyController@index']);
Route::get('extraOTher/{path}', ['as' => 'myprefix.two', 'uses' => 'MyController@indexOther']);
}
);
public function index($path)
{
// $path should be extra/x/x/x/x/x/2/3/2/
}
MyController.php
Route::group(
['prefix' => 'myprefix'],
function () {
Route::get('extra/{path}', ['as' => 'myprefix.one', 'uses' => 'MyController@index']);
Route::get('extraOTher/{path}', ['as' => 'myprefix.two', 'uses' => 'MyController@indexOther']);
}
);
public function index($path)
{
// $path should be extra/x/x/x/x/x/2/3/2/
}
这总是让我犯错误
NotFoundHttpException in RouteCollection.php line 145:
我怎样才能让它工作?我在某个地方读到关于:any and:all的文章,但我也没能让它们正常工作。有点老套
Routes.php:
添加一个模式
Route::pattern('path', '[a-zA-Z0-9-/]+');
现在它将覆盖所有路线
Controller.php:
不优雅。但是它应该能起作用。嗨,itachi,我不能让它继续工作,你确定它能工作吗>啊,不管它能不能工作!那是因为我有一个朋友。在我的道路上,非常感谢!也为我工作