作者 邓超

redirect

... ... @@ -10,4 +10,22 @@ use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
/**
* 非本站链接,中转跳转
* @author:dc
* @time 2023/1/16 9:22
*/
public function redirect($url){
if(!preg_match("/^http(s?):\/\//",$url)){
$url = 'http://'.$url;
}
return redirect($url,302);
}
}
... ...
... ... @@ -69,4 +69,7 @@ Route::get('/page/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where
// 单页的另一种方式
Route::get('/{key}', [\App\Http\Controllers\V2\Index::class,'page'])->where('key','[a-z_\-\d]{2,}');
// 跳转页面
Route::get('/redirect-{url}', [\App\Http\Controllers\Controller::class,'redirect']);
... ...