Laravel 使用Redirect::to()重定向到其他网站

Laravel 使用Redirect::to()重定向到其他网站,laravel,laravel-4,url-redirection,Laravel,Laravel 4,Url Redirection,当我使用Redirect::to($url)时,结果如下: http://localhost/http://mysite.com/foo/bar.html 但是当我使用Redirect::to('http://google.com“)谷歌很好,猜猜我的问题是什么?你需要提供完全符合条件的URL到重定向::到()方法,否则应用程序基URL是预先设置的 $url = 'www.google.com'; // redirects to http://localhost:8888/www.google

当我使用
Redirect::to($url)
时,结果如下:

http://localhost/http://mysite.com/foo/bar.html

但是当我使用
Redirect::to('http://google.com“)
谷歌很好,猜猜我的问题是什么?

你需要提供完全符合条件的URL到
重定向::到()
方法,否则应用程序基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);

要重定向到外部域,请使用完全限定的url,如tiqeet.com

在控制器中,调用return Redirect::designed(“您的完全限定域”)

希望对你有用。在laravel 4.0中使用了它

Route::get('/', function () {

  $url = 'YOUR DOMAIN NAME HERE';  //DOMAIN NAME MUST BE LIKE THIS : https://www.google.com/

  return Redirect::to($url);

});

在中,我仅对API使用Laravel 5.5,因此在web路由文件中,如果有人试图打开API域名,我会将其重定向到我的同一个域

我尝试使用如下值重定向:重定向到(“不管怎样,$url=$object->url;属性有问题吗
$object->url
代表什么?也许
url
属性不使用
http
协议返回url。只需执行
dd($object->url)
即可查看值。