-1

i am using laravel 5 on local on window ..i am trying to redirect the page to some external url..but nothing seems to help me..

i tried

                   return \Response::make('',302)->header('Location','http://site2');
                    return redirect()->away("http://site2");

                    \Redirect::to('http://site2');
                    header('Location: http://site2');

but none of them working..gives no response..

  • Findings: core php function to redirect to external url return header('Location: http://someurl.com'); dont works within laravel..:) – Lakhveer Bawa Mar 12 '16 at 08:35

1 Answers1

0

Something like this :

return redirect()->away('http://site2');

Make sure you also add a return (i.e. return $this->checkSession();) in start().

Drudge Rajen
  • 7,584
  • 4
  • 23
  • 43
  • return redirect()->away("http://site2"); working fine from routes.php but not working in controller – Lakhveer Bawa Mar 12 '16 at 08:12
  • Did you check this "Make sure you also add a return (i.e. return $this->checkSession();) in start()." – Drudge Rajen Mar 12 '16 at 08:13
  • sorry i could not understood this.. my code is return redirect()->away("http://site2"); – Lakhveer Bawa Mar 12 '16 at 08:17
  • solved...there was some other problem in my code..which is solved now :) btw thanks – Lakhveer Bawa Mar 12 '16 at 08:23
  • so what was the problem ? And if you think this answer is useful then please upvote it so that it can be useful to others as well – Drudge Rajen Mar 12 '16 at 08:24
  • 1
    This answer appears to have been copied from http://stackoverflow.com/questions/29158074/laravel-5-redirect-to-an-external-link-outisde-of-localhost-server so the bit about `$this->checkSession` doesn't apply in your case. However, `return redirect()->away('http://site2');` or `return Redirect::away('http://site2');` should both work as long as there isn't something else returning before it. If it doesn't work, please update your question with the error / outcome received. – Joseph Mar 12 '16 at 08:26
  • actually in routes.php Route::get('320-{slug}.html',['as'=>'music.download_song_320', function($slug){ $misc = new \App\Http\Controllers\Admin\MiscController; return $convert_song = $misc->convertSong($slug,'320'); }]); i did not added return ..so it was causing problems – Lakhveer Bawa Mar 12 '16 at 08:30
  • my vote will not be counted as my reputation is 14.. sorry for this – Lakhveer Bawa Mar 12 '16 at 08:44
  • @Joseph How can you say that i copied answer from that URL ? I know how to redirect to extra link in laravel 5 buddy . So, when i saw that i just post the think that i know. – Drudge Rajen Mar 12 '16 at 13:22