I need to use the Maintenance mode
using the artisan command "down"
, but just for some urls...
In my case, i want that all urls that starts with "/admin/*"
continue working.
Is there a solution?
Take a look at app/http/middleware/CheckForMaintenanceMode.php
There is a URI Array:
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
class CheckForMaintenanceMode extends Middleware
{
/**
* The URIs that should be reachable while maintenance mode is enabled.
*
* @var array
*/
protected $except = [
//
];
}
array-example :
protected $except = [
'api/customers',
'api/user'
];
Suggest by @lukasgeiter
I created a middleware that tests my url...
That`s my code:
<?php namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\RedirectResponse;
class Maintanance {
public function handle($request, Closure $next){
if($request->is('admin*') || $request->is('maintanance')){
return $next($request);
}else{
return new RedirectResponse(url('/maintanance'));
}
}
}
After that I created a route
that show de maintenance view:
Route::get('maintanance', function(){
return view('errors.503');
});
Now I can call the command "up"
and the application still under maintenance, but the /admin
urls...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With