C.ryudo C.ryudo - 4 months ago 20
PHP Question

Laravel5:Redirect::to() outside link NotFoundHttpException in RouteCollection.php

I'm developing a Laravel 5 app, I have this route

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


and in this UrlController.php,I have this index method

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


when I test this url
http://localhost:8000/go

it just change to
http://localhost:8000/www.google.com
and have this error
NotFoundHttpException in RouteCollection.php line 161

so what the problem is , Thanks

Answer

you should add protocol before the www.google.com

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