MISS route/default route



Global MISS routing


##If the route match fails, it is a good idea to redirect it to a specified route

If you want to execute a set route after not matching all routing rules, you can register A separate MISS route:

Route::miss('public/miss');

Or use closure definition

Route::miss(function() {
    return '404 Not Found!';
});

Once the MISS route is set, it is equivalent to turning on the forced routing mode

When all defined routes If none of the rules match, it will be routed to the routing address defined by the miss method.

You can limit the request types of MISS routing

// 只有GET请求下MISS路由有效
Route::miss('public/miss', 'get');

Domain name MISS routing

Support setting separate MISS routing for a domain name

Route::domain('blog', function () {
    // 动态注册域名的路由规则
    Route::rule('new/:id', 'news/read');
    Route::rule(':user', 'user/info');
    Route::miss('blog/miss');
});

Group MISS routing

Group supports independent MISS routing, such as the following definition:

Route::group('blog', function () {
    Route::rule(':id', 'blog/read');
    Route::rule(':name', 'blog/read');
    Route::miss('blog/miss');
})->ext('html')
  ->pattern(['id' => '\d+', 'name' => '\w+']);