Magento SSL links

Magento SSL links

July 26, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento SSL links

You’ve successfully configured your Magento store to use SSL links throughout the frontend and backend. You’ve set up your base URLs correctly:

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

Great! Now you’re trying to generate some dynamic links using Magento’s built-in Mage::getUrl() function. You expect consistency across your entire site, but suddenly you find a discrepancy:

// 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/

The protocol is mixed—some links are HTTP, others HTTPS. Why the inconsistency?

Understanding Magento’s URL Generation Logic

Magento has a complex URL generation system designed for flexibility and backward compatibility with older PHP versions. When you call Mage::getUrl(), it uses different mechanisms depending on whether you’re in the frontend or backend.

In the backend (i.e., when an admin is logged in), Magento always generates secure URLs by default, regardless of your configuration settings. This ensures that all administrative functions are protected even if you forget to enable SSL in your settings.

However, in the frontend:

  1. If a cookie named sécurerequest is present with a value of 1 (which happens when a user submits their credentials or visits an admin page), Magento will generate secure URLs.
  2. If no such cookie exists, it falls back to using non-secure URLs.

This is why you see the mix of HTTP and HTTPS in your frontend links—the securerequest cookie isn’t present for most regular visitors.

Resolving the Protocol Discrepancy

To ensure all your links use a consistent protocol (either HTTP or HTTPS), you have a few options:

Option 1: Encode All URLs Manually

You can manually encode all your URLs to force them to be secure. Here’s an example:

// link to CMS page using secure URL
echo Mage::getUrl('help', array('_secure' => true)); //-> https://sub.domain.com/help/

In your Magento admin under System > Configuration > Web, you can set the cookie domain and path to match your secure base URL. This ensures that the securerequest cookie is set for all visitors, forcing Magento to generate secure URLs.

Option 3: Use a Different URL Helper

If you’re using a third-party module or custom code that bypasses Magento’s built-in URL generation system, make sure it adheres to your SSL settings. For example:

// link to CMS page using a third-party URL helper
echo $this->helper('yourmodule')->getUrl('help'); //-> https://sub.domain.com/help/

Best Practices for Magento and SSL

For optimal security and SEO, I recommend following these best practices:

  • Always use secure URLs (https://) throughout your site.
  • Ensure that all third-party modules or custom code respect your SSL settings.
  • Regularly audit your entire site to check for any mixed content warnings.

Remember, even a single non-secure link can trigger browser warnings and harm user trust. It’s crucial to maintain consistency across your protocols.

Conclusion

Understanding Magento’s URL generation logic is key to resolving issues with mixed HTTP and HTTPS links. By manually encoding URLs, setting cookie settings correctly, or using third-party helpers that respect SSL configurations, you can ensure a consistent and secure user experience throughout your Magento store.

For more in-depth guides on Magento configuration and security best practices, I recommend checking out the resources available at LaravelCompany.

Themes Admin Configuration Customers

Our network