>  기사  >  백엔드 개발  >  laravel5 登录如何跳转到登录前的页面?

laravel5 登录如何跳转到登录前的页面?

WBOY
WBOY원래의
2016-06-06 20:24:041351검색

登录后都是跳转后/home,如何跳转到上一页(登录前的页面)/(没有登录前页面才跳转到home)?

每次都是跳转到home这样不是很好,用户还等去倒退或者是历史记录找之前的页面

<code>public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            return redirect('/home');
        }

        return $next($request);
    }</code>

回复内容:

登录后都是跳转后/home,如何跳转到上一页(登录前的页面)/(没有登录前页面才跳转到home)?

每次都是跳转到home这样不是很好,用户还等去倒退或者是历史记录找之前的页面

<code>public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            return redirect('/home');
        }

        return $next($request);
    }</code>

这样看看?

<code>public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            return Redirect::intended('/');
            //return redirect('/home');
        }

        return $next($request);
    }</code>

<code>public function handle($request, Closure $next)
    {
        if ($this->auth->check()) {
            //跳转到/home页
            return redirect('/home');
            
            //登录成功后跳转登录前的那页,但一般我不这么用根据情况使用
            return redirect()->back();
            
            //我一般使用这个,成功后登录我想使用的控制器
            return redirect()->action('IndexController@index');
        }

        return $next($request);
    }</code>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.