gpt4 book ai didi

php - Laravel5:Redirect::to() 外部链接 RouteCollection.php 中的 NotFoundHttpException

转载 作者:可可西里 更新时间:2023-10-31 23:17:05 25 4
gpt4 key购买 nike

我正在开发 Laravel 5 应用程序,我有这条路线

Route::get('/go','UrlController@index');

在这个 UrlController.php 中,我有这个索引方法

public function index(){
return Redirect::to('www.google.com',302);
}

当我测试这个 url http://localhost:8000/go 它只是更改为 http://localhost:8000/www.google.com 并出现此错误 RouteCollection.php line 161 中的 NotFoundHttpException那么问题是什么,谢谢

最佳答案

你应该在 www.google.com 之前添加协议(protocol)

public function index(){
return Redirect::to('https://www.google.com',302);
}

关于php - Laravel5:Redirect::to() 外部链接 RouteCollection.php 中的 NotFoundHttpException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38631485/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com