laravellaravel-fortify

How to change “/login” url with Fortify?


In laravel 9 with Fortify Authentication I see in routes

  GET|HEAD        login ................................................................................................................................................... login › Laravel\Fortify › AuthenticatedSessionController@create
  POST            login .............................................................................................................................. generated::kNTXAE1j2bp8Zq09 › Laravel\Fortify › AuthenticatedSessionController@store

and my login page is opened by “/login” url.

How can I to make this login as “/admin/login” url?

Leaving all Fortify functionality as it was before?

Thanks!


Solution

  • In your FortifyServiceProvider in the boot() method, you should add

    Fortify::ignoreRoutes();
    

    before the default configuration.

    It will tell Fortify to ignore the build-in routes.

    Then you should copy Fortify's routes (./vendor/laravel/fortify/routes/routes.php) to your own routes (./routes/web.php) file.

    Then in your web.php file you can make changes accordingly.