Creating an secure link in Magento is pretty easy. You can use getUrl() function instead of using hardcoded https link. To do so, you need to insert one paramater in your getUrl() function to make your link an secure one. See Examples below.
Creating a link to onestepcheckout page
To get the URL in Magento Controller in http
This will produce a url like http://www.example.com/onestepcheckout/
Now you want to redirect to the secure version. Easy.
For mage core
For phtml File you can do this:
For Static Block
Creating a link to onestepcheckout page
To get the URL in Magento Controller in http
<a href="<?php echo Mage::getUrl('onestepcheckout/’) ?>"></a>Checkout
This will produce a url like http://www.example.com/onestepcheckout/
Now you want to redirect to the secure version. Easy.
For mage core
<a href="<?php echo Mage::getUrl('onestepcheckout/, array('_secure'=>true)) ?>"></a>Checkout
For phtml File you can do this:
<a href="<?php echo $this->getUrl('onestepcheckout/, array('_secure'=>true)) ?>"></a>Checkout
For Static Block
<a href="{{base url=’ 'onestepcheckout/’,array(‘_secure’ =>true)}}</a>Checkout
5 comments:
You can check to make sure that the URL should be secure by using the Mage::getSecure() function, which returns a boolean value. load it via Mage::getModel('core/url')->getSecure();
Hey Paul,
Thanks for sharing, that was also great tips.
Hi,
I hope you can help me.
I have the following code whch end in HTTP, but I need it in HTTPS:
return Mage::getUrl('media') . 'paymentlogo/' . $logo;
Gives: http://www.peta.cl/media/paymentlogo/default/mp10_1.gif
I try using many options from your example to get the HTTPS, but none of them worked for me:
return Mage::getUrl('media', array('secure'=>true)) . 'paymentlogo/' . $logo;
Gives [Wrong]: http://www.peta.cl/media/index/index/secure/1/paymentlogo/default/mp10_1.gif
return Mage::getUrl('media' . 'paymentlogo/' . $logo, array('_secure'=>true));
Gives [Wrong]: https://www.peta.cl/mediapaymentlogo/default/mp10_1.gif/
return Mage::getUrl('media' . '/' . 'paymentlogo/' . $logo, array('_secure'=>true));
Gives [Error]: https://www.peta.cl/media/paymentlogo/default/
Any idea ??
Appreciate your help from Chile !
Regards,
Nicolas
Hi Nicolas,
Try using:
Mage::getUrl('', array('secure'=>true)) . 'media/paymentlogo/' . $logo;
Let me know if it works?
- Janzell
Hi
Thanks for sharing..
Post a Comment