Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 417
mstdmstd Avatar asked Nov 02 '25 01:11

mstdmstd


2 Answers

There is also a more personalized option where you can rename any route separately. Add the following lines in config/fortify.php, inside of the returned array:

 return [

      // existing settings here

      'paths' => [
        'login' => '/admin/login',
       ],   
  ];

You can do this with all named routes.

like image 189
Eduardo Dias Avatar answered Nov 03 '25 16:11

Eduardo Dias


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.

like image 29
geertjanknapen Avatar answered Nov 03 '25 15:11

geertjanknapen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!