Magento – Fix getUrl and getSkinUrl Displaying Insecure Content on HTTPS Pages

ssl

Visitors to my website in HTTPS are receiving messages that some of the content is not secure. Upon investigation it appears that my active template has a getUrl and getSkinUrl code that calls the home button but displays it in HTTP and not HTTPS.

<a href="<?php echo $this->getUrl() ?>"><img src="<?php echo $this->getSkinUrl(); ?>images/Home.gif" alt="<?php echo $this->__('Home');?>"/>

How do I make a call to getUrl and getSkinUrl to generate secure links on secure pages?

Best Answer

first of all, this:

<?php echo $this->getSkinUrl(); ?>images/Home.gif

should be

<?php echo $this->getSkinUrl('images/Home.gif'); ?>

You can pass parameters to getUrl to make it secure:

$this->getUrl('', array('_secure'=>true));
$this->getSkinUrl('images/Home.gif', array('_secure'=>true));
Related Topic