Magento SSL Links
I have configured magento to use SSL links.
Base URL https://sub.domain.com/ Base Link URL {{secure_base_url}} Base ... URL {{secure_base_url}} ... / Use Secure URLs in Frontend: YES Use Secure URLs in Backend: YES
Frontend I have some custom links created with Mage :: getUrl ([...])
<?php
// link to CMS page
echo Mage::getUrl('help'); //-> http://sub.domain.com/help/
// link to customer account
echo Mage::getUrl('customer/account'); //-> httpS://sub.domain.com/customer/account/
?>
Why is there a difference in protocol?
// Roland
+2
source to share
4 answers
I think this is better (from: http://thecompleteprogramer.wordpress.com/2012/09/11/magento-get-url-with-or-without-secure-path-according-to-current-url-protocol / )
Mage::getUrl('yourpath', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
+4
source to share
it worked with me
echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
For example:
if you are browsing http then
echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// http://dominio.com/customer/account/loginPost
if you are browsing https then
echo Mage::getUrl('customer/account/loginPost',array('_secure'=>true));
// https://dominio.com/customer/account/loginPost
0
source to share