Roland Franssen
Roland Franssen

Reputation: 1108

Magento SSL links

I've 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 built 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

Upvotes: 2

Views: 9387

Answers (4)

Greg
Greg

Reputation: 10360

In app/code/core/Mage/Customer/etc/config.xml there's an entry for frontend/secure_url for /customer.

This will help

Upvotes: 4

Juan Carlos Conde
Juan Carlos Conde

Reputation: 159

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

Upvotes: 0

Krzysztof Chełchowski
Krzysztof Chełchowski

Reputation: 119

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()));

Upvotes: 4

I had an issue with https in my custom module; my work around was like this:

$loadFromSSL = $_SERVER['SERVER_PORT']==443?true:false;

Mage::getUrl('', array('_secure'=>$loadFromSSL))

Upvotes: 5

Related Questions