使用Redirect :: to()重定向到另一个网站

9 laravel url-redirection laravel-4

当我使用Redirect::to($url)这个结果时:

http://localhost/http://mysite.com/foo/bar.html
Run Code Online (Sandbox Code Playgroud)

但是,当我使用Redirect::to('http://google.com')它去google就好了,任何猜测我的问题是什么?

And*_*yco 20

您需要提供完全符合条件的URL Redirect::to()方法,否则应用基础URL.

$url = 'www.google.com';
// redirects to http://localhost:8888/www.google.com
return Redirect::to($url);

$url = 'http://google.com';
// redirects to http://google.com
return Redirect::to($url);
Run Code Online (Sandbox Code Playgroud)