简体   繁体   English

如何在laravel上返回重定向

[英]how to return redirect on laravel

i have the problem with the return redirect on laravel 4. how can i return redirect with error? 我在laravel 4上有返回重定向的问题。如何返回有错误的重定向?

public function Verify( $data )
{
    try
    {
        $this->_initSoap( $data['store_url'] );
    } catch (\SoapFault $e) {
        // login failed logic
        $faultcode = $e->faultcode; // ex: 2
        $message = $e->faultstring; // ex: Access denied.
        //die('aaaa'. $message );// return redirect, etc...
        return \Redirect::to('user/stores/magento')->with('error', $message);
    }
}

i got problem like this 我有这样的问题

 ErrorException (E_UNKNOWN) 
Header may not contain more than a single header, new line detected

Open: /var/www/haroldas.ggggg.com/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php

        // status
        header(sprintf('HTTP/%s %s %s', $this->version, $this->statusCode, $this->statusText), true, $this->statusCode);

        // headers
        foreach ($this->headers->allPreserveCase() as $name => $values) {
            foreach ($values as $value) {
                header($name.': '.$value, false, $this->statusCode);
            }
        }

Have you tried using the back method in the redirect? 您是否尝试过在重定向中使用back方法?

Try 尝试

Return \Redirect::back()->with('error', $message);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM