redirect to maintenance page

Let say my application has rbac permission admin and enduser. I has create view /site/maintenance.php as maintenance page.

I want to do something like this

if ($app->user->can('enduser')) {



How can i make the above code/logic apply to all route without writing it in each controller/action?

So all enduser will be redirected to maintenance page, but admin still can access the website as usual.

Try this:

I has install the extension.

I add this code to the component in config/web.php

'maintenanceMode' => [

            'class' => 'brussens\maintenance\MaintenanceMode',

            'enabled' => true,

            'route' => 'site/maintenance',


and add this to bootstrap


But when access the website, it display

Not Found (#404).

If i remove route, the page will keep loading until firefox display

The page isn’t redirecting properly.

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

So what is the basic config to make the extension work?

‘site/maintenance’ is not a correct route!

‘maintenance/index’ is - but you can leave that out.

Routes in modules works slightly different than routes in general, but basically: the module name is path-prepended:


See the guide