How Do You Get The Store Secure URL in Magento?

Josh Pennington picture Josh Pennington · Nov 23, 2010 · Viewed 52.5k times · Source

I have a form in Magento that is displayed over the insecure URL (http) but I need it to submit to the secure URL (https).

I display the URL I currently use the following code:

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)

I am assuming I need to change the URL_TYPE_WEB to something else. Does anyone know what that something else is?

Answer

shaune picture shaune · Nov 23, 2010

Have you tried this?

Mage::getUrl('',array('_secure'=>true))

I think that gets you the base secure url, I believe.

Mage::getUrl('customer/account/login',array('_secure'=>true))

Will get you to the login page. In other words,

Mage::getUrl('module/controller/action',array('_secure'=>true))

Will get you to any page you want, just substitute 'module/controller/action' for the appropriate combo.

Edit -- Fixed Typos