我可以在Magento PHTML文件中检查HTTPS吗?

Kat*_*Vel 20 php magento

我在Magento网站上安装Clicky代码.我想仅在支持HTTPS的Magento页面上使用他们的HTTPS跟踪器.我怎样才能做到这一点?

我试过了

<?php if($_SERVER['https'] == 'on') : ?>
Run Code Online (Sandbox Code Playgroud)

但这不起作用.

有关识别HTTPS页面的任何建议都会有很大帮助!

谢谢.

Jos*_*tey 60

Magento实际上为您提供了一种方法.

使用此选项可检查您是否处于安全模式:

// check to see if your store is in secure mode
$isSecure = Mage::app()->getStore()->isCurrentlySecure();
Run Code Online (Sandbox Code Playgroud)

希望有所帮助!

谢谢,乔


Hai*_*ome 5

原生Magento解决方案

$isSecure = Mage::app()->getFrontController()->getRequest()->isSecure(); 
($isSecure) ? 'https://' : 'http://'; 
Run Code Online (Sandbox Code Playgroud)

这有助于检查您的店面是否为https或http