How to change “/login” url with Fortify?

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

How to Change the Default "/login" URL with Fortify: A Guide

As developers building applications with Laravel, we often find ourselves needing to customize the default routes provided by authentication packages. Laravel Fortify provides a streamlined way to handle authentication scaffolding, and while it’s incredibly convenient, sometimes you need to integrate this flow into a specific application structure, such as placing login pages under an /admin prefix instead of the root /login.

This post will walk you through the precise, clean, and non-destructive way to change your default Fortify login URL without rewriting any of Fortify’s core functionality.

Understanding the Route Structure in Laravel

When you install Laravel Fortify, it registers a set of routes (like /login, /register, etc.) within your application's routing files, typically routes/web.php. These routes are defined based on the configuration provided by the package. To change the URL, we don't need to touch the Fortify code itself; instead, we leverage Laravel’s powerful route grouping features.

The goal is to wrap the necessary authentication routes within a new prefix that reflects your application’s desired structure—in this case, /admin.

The Solution: Using Route Groups for Prefixing

The most robust and maintainable way to achieve this is by utilizing Laravel's Route::prefix() method. This method allows you to define a base URL segment that will be prepended to all routes defined within the closure block. This keeps your application logic clean and adheres to good architectural patterns, which is central to how modern frameworks like those found on laravelcompany.com are designed.

Here is how you can modify your routes/web.php file:

Before Modification (Default Fortify Setup)

Initially, your routes might look something like this, leading to the default /login:

// routes/web.php (Example of default Fortify setup)

use Illuminate\Support\Facades\Route;
use Laravel\Fortify\Fortify as Fortify;

Fortify::routes(); // This often registers /login, /register, etc.

// ... other routes

After Modification (Implementing the /admin/login structure)

To prefix all authentication routes with /admin, you simply wrap the Fortify route calls within a Route::prefix() block:

// routes/web.php

use Illuminate\Support\Facades\Route;
use Laravel\Fortify\Fortify as Fortify;

Route::prefix('admin')->group(function () {
    // All routes defined here will be prefixed with /admin
    Fortify::routes(); // This will now register /admin/login, /admin/register, etc.
});

// ... other application routes

By implementing this change, all the endpoints generated by Fortify—including login forms (GET requests) and login submissions (POST requests)—will automatically be prepended with /admin. This keeps your Fortify setup completely intact while giving you the desired URL structure.

Best Practices and Conclusion

This method is superior to manually editing individual route files because it is scalable and adheres to the principle of separation of concerns. You are not modifying how Fortify handles authentication, but rather controlling where those routes are exposed in your application. This approach ensures that if you ever need to change the base URL (e.g., from /admin to /dashboard), you only need to modify this single block of code.

When working with complex applications built on Laravel, focusing on route organization through prefixes and middleware is crucial for maintaining clean, professional, and maintainable code. Always look for ways to leverage framework features like these routing capabilities to build powerful applications efficiently.

By using route groups, you successfully transformed the default /login into a contextually relevant /admin/login, all while keeping the power of Laravel Fortify fully functional. Happy coding!