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
It's possible to specify URLs that should remain "up" while your application is in maintenance mode. For most applications, you can define these in your app's bootstrap/app.php
file:
return Application::configure(basePath: dirname(__DIR__)) ->withRouting() ->withMiddleware(function (Middleware $middleware) { $middleware->preventRequestsDuringMaintenance(except: [ '/cp*' ]); })
In this example, the Control Panel will be available while the rest of your application is "down".
For older applications, without the Application::configure()
API in the bootstrap/app.php
file, you can instead define exclusions in the app/Http/Middleware/PreventRequestsDuringMaintenance.php
file:
protected $except = [ '/cp*'];