示例$ _SERVER ['REQUEST_URI']是 http://asdf.com/redirect/jhdsjkas/userDetails?redirect_back_url=http://userInfo.com/result?pass
$uri_string = explode("?", $_SERVER['REQUEST_URI']);
if(count($uri_string) > 1){
$url_info = explode("&", $uri_string[1]);
$base_url_string = explode("=", $url_info[0]);
$redirect_to_url = $base_url_string[1].'result?pass';
}else{
$redirect_to_url = '';
}
将Redirect ::返回到($ redirect_to_url);
重定向:: to不起作用,因为它附加了base_url,然后是redirect_to_url字符串。
如何使用Laravel 5.4实现此目的,并将redirect_to_url从REQUEST_URI中获取?
答案 0 :(得分:1)
您可以使用以下命令从URI参数获取值并重定向:
return Redirect::away(request('redirect_back_url'));
答案 1 :(得分:0)
如果是您想要的上述网址中的Redirect URL
。然后你可以从Request
对象
/** Request $request <---> it is normally passed as parameter in routed functions **/
if($request->has('redirect_back_url')){
// response()->redirect($request->get('redirect_back_url')); **
Redirect::away($request->get('redirect_back_url'));
}else{
// return some error
}