phplaravellaravel-5

Laravel - Maintenance mode just for some urls


I need to use the "Maintenance mode" using the artisan command php artisan down, but just for some specific urls...

In my case, I want that all urls that starts with /admin continue working.

Is there a solution?


Solution

  • 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 Maintenance {
        public function handle($request, Closure $next){
            if($request->is('admin*') || $request->is('maintenance')){
                return $next($request);
            }else{
                return new RedirectResponse(url('/maintenance'));
            }
        }
    }
    

    After that I created a route that show de maintenance view:

    Route::get('maintenance', function(){
        return view('errors.503');
    });
    

    Now I can call the command "up" and the application still under maintenance, but the /admin urls...