Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel-使用通配符路由处理页面_Php_Laravel_Routes_Laravel 5.1 - Fatal编程技术网

Php Laravel-使用通配符路由处理页面

Php Laravel-使用通配符路由处理页面,php,laravel,routes,laravel-5.1,Php,Laravel,Routes,Laravel 5.1,在我的应用程序中,我需要设置一个响应任何页面的路由 我已将我的routes.php文件放入: // Handle all the pages Route::get('{slug?}', 'Frontend\PageController@show'); 它是有效的,问题是现在我需要一个管理部分,所以在我的routes.php中,我在上一条路径之前添加了: Route::group( [ 'prefix' => 'admin', 'middleware' => config('admi

在我的应用程序中,我需要设置一个响应任何页面的路由

我已将我的
routes.php
文件放入:

// Handle all the pages
Route::get('{slug?}', 'Frontend\PageController@show');
它是有效的,问题是现在我需要一个管理部分,所以在我的
routes.php
中,我在上一条路径之前添加了:

Route::group( [ 'prefix' => 'admin', 'middleware' => config('admin.filter.auth') ], function(){
    // other routes
}  );
问题是url
site.com/admin
已被通配符捕获,因此我无法访问该url

这是完整的路由文件:

//admin routes
Route::group( [ 'prefix' => 'admin', 'middleware' => config('admin.filter.auth') ], function(){

    Route::get('upload-file', 'Backend\UploadController@index');
    Route::post('upload-file', 'Backend\UploadController@uploadFile');
    Route::get('load-contacts', 'Backend\UploadController@loadContacts');

}  );

// Handle all the pages
Route::get('{slug?}', 'Frontend\PageController@show');

我应该如何管理它?

您可以通过提供一个正则表达式来轻松实现这一点,该正则表达式应用于匹配您的slug参数:

Route::get('{slug?}', 'Frontend\PageController@show')->where('slug', '.*');
/admin路径被catch all路由捕获的原因是您没有为/admin URL定义路由。将单独处理的唯一URL是

GET  /admin/upload-file
POST /admin/upload-file
GET  /admin/load-contacts

我试过了,但没用。即使有了这个代码,
admin
也被
PageController
捕获了。哈哈,对不起,我没有注意到其他的路由,我会马上更新答案