반응형
지정된 Laravel URL로 리디렉션
매개 변수가 완전한 URL인 레이블의 리디렉션 클래스에 메서드가 있습니까?우리는 모두 이 메소드들의 매개 변수가 단지 경로 이름, 액션, 슬래시 등이라는 것을 알고 있지만, 지금 내가 원하는 것은 다음과 같습니다.
return Redirect::foo('https://bla.com/?yken=KuQxIVTNRctA69VAL6lYMRo0');
네, 그렇습니다.
use Illuminate\Support\Facades\Redirect;
return Redirect::to('http://heera.it');
업데이트: Redirect::away('url')
(외부 링크의 경우, Laravel Version 4.19):
public function away($path, $status = 302, $headers = array())
{
return $this->createRedirect($path, $status, $headers);
}
다양한 유형의 리디렉션 방법을 사용할 수 있습니다.
return redirect()->intended('http://heera.it');
OR
return redirect()->to('http://heera.it');
OR
use Illuminate\Support\Facades\Redirect;
return Redirect::to('/')->with(['type' => 'error','message' => 'Your message'])->withInput(Input::except('password'));
OR
return redirect('/')->with(Auth::logout());
OR
return redirect()->route('user.profile', ['step' => $step, 'id' => $id]);
사용할 수도 있습니다.redirect()
다음과 같은 방법:
return redirect('https://stackoverflow.com/');
둘다요.Redirect::to()
그리고.Redirect::away()
작동해야 합니다.
차이
추가 URL 검사 및 생성을 수행합니다.: to()로 리디렉션합니다.이러한 추가 단계는 Illuminate\에서 수행됩니다.라우팅\UrlGenerator를 사용하여 전달된 URL이 완전히 유효한 URL이 아닌 경우 다음을 수행합니다(프로토콜을 사용하더라도).
Determines if URL is secure rawurlencode() the URL trim() URL
src : https://medium.com/ @zwaky/laravel-twaky-to-vs-twak-away-dd875579951f
이것은 Laravel 5.8에서 작동했습니다.
return \Redirect::to('https://bla.com/?yken=KuQxIVTNRctA69VAL6lYMRo0');
또는 / 대신 사용할 수 있습니다.
use Redirect;
우리는 최신 라라벨 버전에서 사용할 수 있습니다.
return redirect()->away('https://www.google.com');
쿼리 매개 변수를 전달하려는 경우:
$redirectUrl = $request->redirect_url.'/reset-password?token='.$request->token.'&email='.$request->email;
return redirect()->away($redirectUrl);
언급URL : https://stackoverflow.com/questions/18626492/redirect-to-a-given-laravel-url
반응형
'sourcecode' 카테고리의 다른 글
정의되지 않은 행 선택 (0) | 2023.09.05 |
---|---|
프로그래밍 방식으로 UI 세그먼트 컨트롤을 전환하는 방법은 무엇입니까? (0) | 2023.09.05 |
MariaDB 기반 모델링 도구 (0) | 2023.09.05 |
LESS 변수의 알파 불투명도 수정 (0) | 2023.09.05 |
백만 개의 숫자 문자열이 주어지면 반복되는 모든 3자리 숫자를 반환합니다. (0) | 2023.09.05 |