1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

laravel ログイン関連 URL変更

Last updated at Posted at 2022-12-15

●laravelのログイン機能を使うとデフォルトでURLが決められている。
・ログイン・・・/login
・新規登録・・・/register など

●上記のURLを変更する方法は以下の通り
1.「プロジェクトフォルダ」->vendor->laravel->framework->src->Illuminate->Routing->Router.phpを開く
2.auth()メソッドを探す。
3.書き換える。
修正前

    public function auth()
    {
        // Authentication Routes...
        $this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
        $this->post('login', 'Auth\LoginController@login');
        $this->post('logout', 'Auth\LoginController@logout')->name('logout');

        // Registration Routes...
        $this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
        $this->post('register', 'Auth\RegisterController@register');

        // Password Reset Routes...
        $this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
        $this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
        $this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
        $this->post('password/reset', 'Auth\ResetPasswordController@reset');
    }

修正後

    public function auth()
    {
        // Authentication Routes...
        $this->get('プロジェクト名など/login', 'Auth\LoginController@showLoginForm')->name('login');
        $this->post('プロジェクト名など/login', 'Auth\LoginController@login');
        $this->post('プロジェクト名など/logout', 'Auth\LoginController@logout')->name('logout');

        // Registration Routes...
        $this->get('プロジェクト名など/register', 'Auth\RegisterController@showRegistrationForm')->name('register');
        $this->post('プロジェクト名など/register', 'Auth\RegisterController@register');

        // Password Reset Routes...
        $this->get('プロジェクト名など/password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
        $this->post('プロジェクト名など/password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
        $this->get('プロジェクト名など/password/reset/{token}', 'Auth\ResetPasswordController@showResetForm')->name('password.reset');
        $this->post('プロジェクト名など/password/reset', 'Auth\ResetPasswordController@reset');
    }

これで
「プロジェクト名など/〇〇〇」でアクセスできる。

●参考
https://reffect.co.jp/laravel/laravel-authentification-by-code-base

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?