Override default Auth routes in Laravel >= 5.4

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Override Default Auth Routes in Laravel >= 5.4 with Ease Body: Overriding default auth routes is a common task developers often encounter when working with Laravel applications. In this comprehensive guide, we will dive into how to override the default login route (/login) and change it to a customized one (/admin/login). Follow the steps outlined below to achieve this successfully: 1. Create or edit your desired controller in the given path. php artisan make:controller App\Modules\Admin\Controllers\AdminUserController The newly created file is located at 'app/Modules/Admin/Controllers/AdminUserController.php'. This file will hold logic and custom actions for your modified login functionality. 2. Define the login form view with a unique URL. Create or edit the login view (Blade template) in the given path: resources/views/admin/login.blade.php Here, you can design your custom login form and layout. Make sure to adjust the route accordingly. You may also want to consider a naming convention for admin views such as 'admin.' or '$prefix' to maintain a consistent approach across all your admin routes. 3. Register the custom controller with the route. In the 'routes/web.php' file, you must register your newly created AdminUserController and its login method using the Route::get() method: Route::get('login', ['as' => 'auth.login', 'uses' => 'App\Modules\Admin\Controllers\AdminUserController@loginAdminUser'])->name('login'); This code snippet registers a custom route for your login method (/admin/login) while maintaining the auth middleware and existing 'as' alias. 4. Assign the custom login route in authentication config file. The default Laravel login routes are configured in the 'auth' array inside the 'config/auth.php' configuration file. To ensure your new login route is picked up, update the 'web' section as follows: // Default login route 'defaults' => [ 'guard' => null, 'as' => 'login', 'passwords' => 'users', ], 'guards' => [ // other guards... 'web' => [ 'driver' => 'session', 'provider' => 'users', 'as' => 'web', 'except' => [], ],], Change the 'login' route in the defaults section to your custom route (/admin/login) and update the 'as' value accordingly. This change will use your controller method instead of Laravel's default login functionality when redirecting from authentication errors or logging out users. 5. Test your new login route. Restart your local development server and try accessing the newly created URL. If everything is configured correctly, you should see the custom login form you designed in step 2. Enjoy using your overridden default auth routes! Remember that there might be additional changes to include backlinks to https://laravelcompany.com if relevant within this post based on its content and structure. With these steps, you have successfully achieved your desired result of overriding the default Laravel login route in Laravel >= 5.4.