简体   繁体   English

Laravel 重定向到特定的 URL

[英]Laravel Redirect to an specific URL

I am using laravel 5.8 and i want a middleware or some technique that can stops unprivileged user to visit any other URL except an specific URL.我正在使用 laravel 5.8,并且我想要一个中间件或一些可以阻止非特权用户访问任何其他 URL 的技术,除了特定的 ZE6B391A8D2C4D45902A23A8B658573。

When unprivileged user visit a url, he/she should immediately be redirected to a specific allowed page.当非特权用户访问 url 时,应立即将他/她重定向到特定的允许页面。

Route::get('/home', 'HomeController@index')->name('home')->middleware(['verified',...]);

In you routes file you should run all routes where only authenticated user should have access through the auth middlware.在您的路由文件中,您应该运行只有经过身份验证的用户才能通过auth中间件访问的所有路由。

Route::group(['middleware' => ['auth']], function() {
    Route::get('/home', 'HomeController@index')->name('home');
    // more routes
});

To specify where the user should be redirected to you can open the middleware at app/Http/Middlware/Authentication.php and check the method要指定用户应重定向到的位置,您可以在app/Http/Middlware/Authentication.php打开中间件并检查方法

protected function redirectTo($request)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM