I Googled it but maybe my search keywords are useless so how can I get URL protocol in controller? IS it http:// or https://
http://whatever.com/app_dev.php/welcome
//I need to echo http:// protocol here
echo $request->getHost(); //echos whatever.com
echo $request->getBaseUrl(); //echos app_dev.php/
You can use this in your controller :
$scheme = $this->getRequest()->getScheme();
Otherwise, here is a code allowing you to know all the values returned by the server:
foreach ($_SERVER as $key => $value) {
echo $key.' => '.$value.'<br>';
}
To check if request is https
use:
$request->isSecure()
Check doc for more info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With