How Do You Get The Store Secure URL in Magento?

52,783

Solution 1

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

Solution 2

http://blog.geekslikeshinythings.com/2014/12/magento-force-secure-urls-https-on-all.html

this works in Mageno 1.9.1 use your app/etc/config.xml file

<?xml version="1.0"?>
<config>
  <frontend>
    <secure_url>
      <all>/</all>
    </secure_url>
  </frontend>
</config>

If user is using https, this should force all urls to rewrite (created as) to https.

Solution 3

Use:

    Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL);

to read the the configuration value inside magento that has been set inside admin.

Solution 4

this worked to me

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));

For example:

if you browsing with http then

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// http://dominio.com/customer/account/loginPost

if you browsing with https then

echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// https://dominio.com/customer/account/loginPost

Solution 5

You can do this in code and also from xml.

For example, if you want to set https for the check out page then you have to add the below code in your custom config.xml:

<code>
        <secure_url>
                <checkout_onepage>/checkout/onepage</checkout_onepage>
                <checkout_multishipping>/checkout/multishipping</checkout_multishipping>
        </secure_url>
</code>

Magento has a default feature for https for check out so you can do the same thing for other pages like for the customer page:

<code>
        <secure_url>
                <customer>/customer/</customer>
        </secure_url>
</code>

I hope it'll help you.

Share:
52,783
Josh Pennington
Author by

Josh Pennington

Just your average everyday programmer@joshpenningtongooglefacebook

Updated on March 08, 2020

Comments

  • Josh Pennington
    Josh Pennington over 4 years

    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?