Excluding the control panel from maintenance mode

Laravel's maintenance mode is a great way to notify visitors that your site is down but will be shortly. But what if you still want to get into the control panel? Here's how.

Overview

When your site is in Laravel’s maintenance mode, a custom view will be displayed for all requests into your site. This makes it easy to “disable” your site while it is updating or when you are performing maintenance. The logic for this mode is handled in the default middleware.

To enable maintenance mode, run the down Artisan command:

php artisan down

And to disable maintenance mode, run the reverse up Artisan command:

php artisan up

Excluding URLs

URLs that should remain “up” while in maintenance mode can be defined in your app/Http/Middleware/CheckForMaintenanceMode.php file. Assuming your control panel uses the default /cp URL, use the following config to exclude it:

// app/Http/Middleware/CheckForMaintenanceMode.php

protected $except = [
    '/cp',
    '/cp/*'
];
Betterify this page on Github!