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

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'));

If this sounds like your situation, let's talk

No pitch decks. No sales process. Just a conversation about what you're dealing with and whether I can help.

Book a 30-minute call →