Magento – Check for Secure / Unsecure URLs in code

Here’s a quick way to check if you are in a secure URL, such as would happen if you have “Use Secure URLs in Frontend” enabled. This code can be placed within phtml files to check the URL.

if (Mage::app()->getStore()->isCurrentlySecure()) { 
    //you are on a secured page
} 
else { 
    //normal, unsecure, http:// URL
}?>
Posted in Magento, Magento Enterprise, Magento Professional, PHP