如何修复我的预期网站 URL 的更改?

How can fix the change of my intended Website URL?

我为我的网站创建了一个授权。我发现如果用户已登录,他将无法返回主页,因为他现在位于仪表板中。在 Whosebug

的帮助下,我将生成的 home.blade.php 中的所有内容更改为 dashboard.blade.php 以及 home 的所有相关引用

现在我收到一个尴尬的错误。如果我从仪表板注销并希望重定向到 http://localhost:8888/ (welcome.blade.php), i get http://localhost:8888/login (login.blade.php).

如果我在注销后单击左上角的 navbrand 会更尴尬,我不会重定向到 http://localhost:8888/ instead i get redirected to http://localhost:8888/login

  1. 我更改了 web.php 路线。我在 'auth' 和 'guest' 之间添加了组。
  2. 如果登录用户尝试将 url 从“/dashboard”操纵到“/”,他将被重定向。
  3. 我安装 Laravel/telescope 是为了更好地了解错误,但对于我这个初学者来说,它真的很混乱
  4. 我将 hone.blade.php 更改为 dashboard.blade.php 以及与 'home'
  5. 相关的所有内容
  6. 也尝试寻找解决方案并使用 Whosebug 用户的代码在用户注销后重定向 (LoginController.php),但不起作用

web.php

Route::group(array(['middleware'=>['guest']]), function(){

  Route::get('/', function () {
    return view('welcome');
  });
});



Auth::routes();


// Only logged user
Route::group(array('middleware'=>'auth'), function(){
  Route::get('/dashboard', 'DashboardController@index')->name('dashboard');

  Route::get('/', function () {
    return redirect('/dashboard');
  });


});

LoginController.php

use Illuminate\Http\Request;
protected function loggedOut(Request $request) {
      return redirect('/');
    }

所以我不能放一张 telescope 的图片,但我想我可以尝试用文字重新创建图片。

预期结果:我不太了解HTTP-Status所以我做了200个

Verb| Path       | Status

Here by '/' should be viewed welcome.blade.php

GET | /          | 200

POST| /logout    | 200

GET | /dashboard | 200

The user can't visit the Path '/' because he is now in dashboard website.

GET | /          | 200

POST| /login     | 200

实际结果:

Verb| Path       | Status
GET | /login     | 200

GET | /          | 302

POST| /logout    | 302

GET | /dashboard | 200

GET | /          | 302

POST| /login     | 302

如果你们有任何问题并希望看到更多 类 那么请问我。我不知道什么与错误有关。我的想法主要是web.php路由错误

最好的问候 托比亚斯

您是否检查过您预定回家的控制器或路线。 例如在你的 web.php 中,我明白了,

    Route::get('/', function () {
    return view('welcome');
      });
    });

然后在认证路由中

Route::get('/', function () {
       return redirect('/dashboard');
      });

错误是您两次使用同一条路线。

重写 web.php 中的代码:

Route::get('/', HomeController@index);

Auth::routes();`

// Only logged user
Route::group(array('middleware'=>'auth'), function(){
    Route::get('/dashboard', 'DashboardController@index')->name('dashboard');
});

并在 HomeController 中编写您的逻辑:

public function index()
{
    return Auth::guest() ? view('welcome') : redirect('/dashboard');
}