域名路由与分组路由结合实践

浏览:1685 发布日期:2018/09/08 分类:求助交流 关键字: thinkphp5 域名路由 分组路由 URL美化
// 前台网站访问规则
// 域名绑定到blog网站模块
Route::domain(['域名1'], function () {
    Route::group('blog', function () { //blog
        //Blog About
        Route::get('about','about');
        //Blog Comment
        Route::get('comment','comment');
        //Blog Details
        Route::get('details','details');
        //Blog Message
        Route::get('message','message');
        //Blog Miss
        Route::miss('Blog/index');
    })->prefix('index/Blog/');
})->cache(3600);

// 前台网站访问规则
// 域名绑定到index网站模块
Route::domain(['域名a','域名b'], function () {
    Route::group('', function () { //site
        //Category
        Route::get('list-<catid>-<c?>','lists')
            ->pattern(['c' => '\w+', 'catid' => '\d+'])
            ->name('product_lists');
        //Details
        Route::get('item-<catid>-<id>-<i?>','details')
            ->pattern(['i' => '\w+', 'id' => '\d+', 'catid' => '\d+'])
            ->name('product_details');
        //Preview
        Route::get('preview-<catid>-<id>-<t?>','preview')
            ->pattern(['t' => '\w+', 'id' => '\d+', 'catid' => '\d+'])
            ->name('product_preview');
        //Search
        Route::get('search-<catid?>/<q?>','search')
            ->pattern(['q' => '\w+', 'catid' => '\d+'])
            ->name('site_search');
        //Pages
        Route::get('<page>','pages')
            ->pattern(['page' => '\w+'])
            ->name('site_pages'); 
        //Miss
        Route::miss('Index/index');
    })->prefix('index/Index/');
})->cache(3600);
最佳答案
评论( 相关
后面还有条评论,点击查看>>