5

I want to return a view from my controller function with https or http depending on a variable. I don't want to redirect it to https or http and I only want to use View::make() or Response::view() function. Is it possible?

Example:

public function getSiteContent($https = false)
{
  if($https===true){
    //return to secure https url
    return View::make('sites.content');
  }
  else{
    //return to http url
    return View::make('sites.content');
  }
}
Mokhlesur Rahman
  • 751
  • 7
  • 25
  • 3
    If you want to change the protocol the user is using then you would **have** to redirect, there is no alternative. – Jono20201 Apr 20 '15 at 09:20
  • @Jono20201, My concept and thinking is if we are going to a new url than we should have control over protocol. If we can change headers by `Response::view()` than why we can't change the protocol? – Mokhlesur Rahman Apr 20 '15 at 09:25
  • @interstellarDust because response depends on request. In order to return https response you need to make https request. – Limon Monte Apr 20 '15 at 09:36

1 Answers1

-2

First I understood question wrong. Returning view just returns the content on the page and View does not have anything to do with the protocol.

If protocol change is needed then only way is to redirect to https or http whatever you prefer.

Margus Pala
  • 8,433
  • 8
  • 42
  • 52