How do you get secure or unsecure urls in magento? It's quite simple actually. We discussed about getting different base url types in previous blog post here - [Magento get base url].
Now we will show you how to get secure urls in magento. So in previous post we got base url as:
Mage::getBaseUrl(); Mage::getBaseUrl('skin'); // etc...
Also, in one of our previous magento post, we mentioned this:
Mage::getUrl('');
Now, we are going to add extra param, so magento returns secure url as we are after. We just need to add 'true' as second parameter when we need secure url.
Mage::getBaseUrl('type_of_link', 'secure_or_unsecure'); Mage::getBaseUrl('', true); Mage::getBaseUrl('skin', true);
And for: Mage::getUrl($route, $params); you can pass array('_secure'=>true) as second parameter to get secure urls like this:
Mage::getUrl('',array('_secure'=>true)); Mage::getUrl('mymodule/mycontroller/action', array('_secure'=>true));
References:
Mage.php and app/code/core/Mage/Core/Model/Store.php
Top Magento Extension to Power Your Magento Store posted on - Tuesday 11th of November 2014 01:38:13 AM
Magento Development posted on - Wednesday 30th of August 2017 11:49:43 AM