您好,欢迎来到 速建时代开源商城!
thinkphp6路由设置
web制作教程

399

路由设置为了简化url地址,可自定义路由,源url地址为 http://phpcms.hbsjsd.cn/cata/index?cid/12.html 简化后http://phpcms.hbsjsd.cn/cates-12.html

1、路由设置 域名/cates/1.html
Route::group('cates', function () {
    Route::rule('/:cid', '/cate/index');
    Route::rule('/:cid', 'cate/index');
})->ext('html')->pattern(['method' => 'get', 'cid' => '\d+']);
Route::group('page', function () {
    Route::rule('/:cid', '/page/index');
    Route::rule('/:cid', 'page/index');
})->ext('html')->pattern(['method' => 'get', 'cid' => '\d+']);
Route::group('art', function () {
    Route::rule('/:aid', '/article/index');
    Route::rule('/:aid', 'Article/index');
})->ext('html')->pattern(['method' => 'get', 'aid' => '\d+']);
2、路由设置 域名/cates-1.html
Route::get('cates-'.":cid", '/cate/index')->ext('html')->pattern(['method' => 'get', 'cid' => '\d+']);
Route::get('page-'.":cid", '/page/index')->ext('html')->pattern(['method' => 'get', 'cid' => '\d+']);
Route::get('art-'.":aid", 'Article/index')->ext('html')->pattern(['method' => 'get', 'aid' => '\d+']);