简体   繁体   中英

laravel 5 routes where in group

I wanna create url like this

http://example.com/url1/product/blabla http://example.com/url2/product/aiueo

I can't achieve with this

Route::prefix('{page}')->name('the_url')->group(function () {
    Route::get('/', 'HomeController@page')
        ->name('index');

})->where('page', '(url1|url2)');

Or should I use the where() in every method inside the {page} prefix?

You can use it with group like this:

Route::group([
    'as' => 'the_url',
    'prefix' => '{page}', 
    'where' => [
        'page' => 'url1|url2'
    ],
], function () {
    // Group routes
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM