Instructions to enable maintenance mode in Laravel 8.
- Tram Ho
The problem to share with you is when you enable maintenance mode in laravel 8 with the command php artisan down
or Artisan::call("down")
. At that time, if you go to any link of the website, you will only receive the following message “503 | SERVICE UNAVAILABLE”.
Now we want to access some of the links while maintenance mode is still on. For example, just access the admin page of the website, for example.
You guys come in: App/Http/Middleware/PreventRequestsDuringMaintenance.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; class PreventRequestsDuringMaintenance extends Middleware { /** * The URIs that should be reachable while maintenance mode is enabled. * * @var array */ protected $except = [ ]; } |
You change it back to:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?php namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware; class PreventRequestsDuringMaintenance extends Middleware { /** * The URIs that should be reachable while maintenance mode is enabled. * * @var array */ protected $except = [ // 'admin/*', 'admin' ]; } |
The above code is meant to allow access to paths http://localhost/admin , http://localhost/admin/* in maintenance mode. (ex: * = san-pham || * = them-san-pham). Good luck