You Are Here: Home » Uncategorized

Laravel: How to disable web.php Route and redirect everything?

By Debjit on August 19th, 2021 
Advertisement

In order to redirect everything on web routes, you can add the following piece of code in your app's route/web.php file

Route::any( '{catchall}', function(){
        // return redirect( 'https://digitizor.com' )
        // OR, Do something here
})->where( 'catchall', '.*' );

In order to complete disable the web.php routes and just use Laravel for API, you need to comment out the following section in the boot() method under the RouteServiceProvider class in the app/Providers/RouteServiceProvider.php file.

            // Do not want any web routes
            // Route::middleware('web')
            //     ->namespace($this->namespace)
            //     ->group(base_path('routes/web.php'));

Advertisement







Laravel: How to disable web.php Route and redirect everything? was originally published on Digitizor.com on August 18, 2021 - 12:35 pm (Indian Standard Time)