作者 邓超

redirect

@@ -10,4 +10,22 @@ use Illuminate\Routing\Controller as BaseController; @@ -10,4 +10,22 @@ use Illuminate\Routing\Controller as BaseController;
10 class Controller extends BaseController 10 class Controller extends BaseController
11 { 11 {
12 use AuthorizesRequests, DispatchesJobs, ValidatesRequests; 12 use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
  13 +
  14 +
  15 +
  16 + /**
  17 + * 非本站链接,中转跳转
  18 + * @author:dc
  19 + * @time 2023/1/16 9:22
  20 + */
  21 + public function redirect($url){
  22 + if(!preg_match("/^http(s?):\/\//",$url)){
  23 + $url = 'http://'.$url;
  24 + }
  25 +
  26 +
  27 + return redirect($url,302);
  28 + }
  29 +
  30 +
13 } 31 }
@@ -69,4 +69,7 @@ Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where @@ -69,4 +69,7 @@ Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where
69 // 单页的另一种方式 69 // 单页的另一种方式
70 Route::get('/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}'); 70 Route::get('/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}');
71 71
  72 +// 跳转页面
  73 +Route::get('/redirect-{url}', [\App\Http\Controllers\Controller::class,'redirect']);
  74 +
72 75