• Email: [email protected]
  • Dedicated Server Login
  • About
  • 9288041031
  • Knowledge Base
  • Support
India's best web hosting | Ehostpiya India
  • Home
  • Hosting
    Web Hosting Quality Hosting Starting at ₹60/mo
    Cloud VPS Starting at ₹300/mo
    Dedicated Server First Starting at ₹2401/mo
    Reseller Web Hosting Conveniently Starting at ₹421/mo
    Application For Hosting
    • iconWordPress Hosting
    • iconJoomla Hosting
    • iconMagento Hosting
    • iconOpencart Hosting
    • iconPrestashop Hosting
    • iconDrupal Hosting
  • Email
  • Domain
  • SVG
    Contact Us Face any problem contact with us
    SVG
    About Us We are leading hosting company
  • My Account
Web Hosting Blogs by Ehostpiya | Tips and Tricks Web Hosting Blogs by Ehostpiya | Tips and Tricks
Buy Now

Archives

  • October 2026
  • September 2026
  • August 2026
  • October 2023

Categories

  • Control Panels
  • Magento
  • Miscellaneous
  • SEO
  • Technology
  • Trends
  • Web Hosting
  • Wordpress
Facebook Twitter Instagram Pinterest
Home How to Force HTTPS in Magento?
ByVandeeta
October 6, 2026

How to Force HTTPS in Magento?

Table of Contents

Toggle
  • How to Force HTTPS in Magento
    • Why Force HTTPS in Magento?
    • 1. Install an SSL Certificate
    • 2. Configure Magento Base URLs
    • 3. Enable Secure URLs on the Storefront
    • 4. Enable HTTPS for the Magento Admin
    • 5. Configure HTTPS Using Magento CLI
    • 6. Redirect HTTP to HTTPS
    • 7. Force HTTPS with Apache
    • 8. Force HTTPS with Nginx
    • 9. Clear Magento Cache
    • 10. Check for Mixed Content
    • 11. Update Hard-Coded HTTP URLs
    • 12. Check Magento Media URLs
    • 13. Configure HTTPS Behind a CDN or Proxy
    • 14. Use HSTS Carefully
    • 15. Test the Entire Magento Store
    • Common HTTPS Problems
      • Redirect Loop
      • Mixed Content Warning
      • Admin Panel Not Loading
      • Too Many Redirects
    • Magento HTTPS Checklist
    • Conclusion

How to Force HTTPS in Magento

HTTPS is essential for a secure Magento store. It encrypts communication between your customers and the server, protects login sessions, and helps prevent sensitive information from being intercepted.

Magento can be configured to use HTTPS for both the storefront and Admin Panel. You should also redirect HTTP requests to HTTPS at the web-server level so visitors cannot continue accessing the website through insecure URLs.

Why Force HTTPS in Magento?

Forcing HTTPS provides several benefits:

  • Protects customer login information
  • Secures administrator sessions
  • Protects checkout traffic
  • Prevents mixed-content problems
  • Improves customer trust
  • Supports modern browser security requirements
  • Helps maintain consistent canonical URLs

A secure Magento website should generally use:

https://example.com

instead of:

http://example.com

1. Install an SSL Certificate

Before forcing HTTPS, your domain must have a valid SSL/TLS certificate.

You can obtain a certificate through your hosting provider or a certificate authority.

After installation, verify that:

https://example.com

opens successfully without certificate warnings.

Also test important pages such as:

  • Homepage
  • Category pages
  • Product pages
  • Customer login
  • Cart
  • Checkout
  • Magento Admin

Do not force HTTPS until the certificate is working correctly.


2. Configure Magento Base URLs

Magento has separate configuration settings for the secure and unsecure base URLs.

From the Magento Admin Panel, go to:

Stores → Configuration → General → Web

Expand:

Base URLs

For a production HTTPS store, configure the Base URL using HTTPS:

https://example.com/

Then expand:

Base URLs (Secure)

Set:

Secure Base URL
https://example.com/

Make sure there is a trailing /.


3. Enable Secure URLs on the Storefront

Under:

Stores → Configuration → General → Web → Base URLs (Secure)

Set:

Secure Base URL

to:

https://example.com/

Then set:

Use Secure URLs on Storefront

to:

Yes

This tells Magento to generate storefront links using HTTPS.


4. Enable HTTPS for the Magento Admin

In the same Base URLs (Secure) section, set:

Use Secure URLs in Admin

to:

Yes

This ensures the Magento administrator interface uses HTTPS.

The Admin Panel should never be accessed over an insecure HTTP connection on a production store.


5. Configure HTTPS Using Magento CLI

You can also update the Magento base URLs from the command line.

From the Magento root directory:

php bin/magento setup:store-config:set \
--base-url-secure="https://example.com/"

Replace example.com with your actual domain.

You can also configure the secure base URL explicitly:

php bin/magento config:set web/secure/base_url "https://example.com/"

Enable secure storefront URLs:

php bin/magento config:set web/secure/use_in_frontend 1

Enable secure Admin URLs:

php bin/magento config:set web/secure/use_in_adminhtml 1

Then flush the Magento cache:

php bin/magento cache:flush

6. Redirect HTTP to HTTPS

Changing Magento’s base URL is not enough.

Someone could still visit:

http://example.com

unless the web server redirects HTTP requests.

You should configure a permanent redirect from HTTP to HTTPS.

The exact configuration depends on your web server.


7. Force HTTPS with Apache

If your Magento store uses Apache, an HTTP-to-HTTPS redirect can commonly be configured with .htaccess.

A typical redirect is:

RewriteEngine On

RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Place the redirect in the appropriate HTTP virtual host or Magento .htaccess configuration according to your server setup.

Be careful when adding redirect rules to an existing Magento .htaccess file. Incorrect rules can cause redirect loops or interfere with Magento routing.


8. Force HTTPS with Nginx

If Magento is running behind Nginx, configure the HTTP server block to redirect requests to HTTPS.

For example:

server {
    listen 80;
    server_name example.com www.example.com;

    return 301 https://$host$request_uri;
}

Your HTTPS server block should then handle the secure Magento traffic.

After modifying Nginx configuration, test it:

nginx -t

If the test succeeds, reload Nginx:

systemctl reload nginx

9. Clear Magento Cache

After changing HTTPS configuration, flush Magento’s cache:

php bin/magento cache:flush

If you use Varnish or another caching system, clear or refresh that cache as well.


10. Check for Mixed Content

After enabling HTTPS, check your website for mixed-content warnings.

Mixed content occurs when an HTTPS page attempts to load resources using HTTP, for example:

http://example.com/media/image.jpg

instead of:

https://example.com/media/image.jpg

Common sources include:

  • Images
  • CSS
  • JavaScript
  • Fonts
  • Third-party scripts
  • Custom theme code
  • Hard-coded URLs in extensions

Browser developer tools can help identify insecure resources.


11. Update Hard-Coded HTTP URLs

Search your Magento configuration, theme, extensions, and custom code for hard-coded HTTP URLs.

For example:

http://example.com/

should generally become:

https://example.com/

Be careful when performing database replacements. Always create a database backup first, and don’t blindly replace serialized Magento data with a basic SQL string replacement.


12. Check Magento Media URLs

Images and other media files should also load over HTTPS.

Check product pages, category pages, banners, and CMS content for HTTP URLs.

For example:

http://example.com/media/catalog/product/image.jpg

should be served securely through HTTPS.


13. Configure HTTPS Behind a CDN or Proxy

If your Magento store uses a CDN, reverse proxy, or load balancer, HTTPS configuration requires additional care.

The visitor may connect like this:

Customer
   ↓
HTTPS
   ↓
CDN / Proxy
   ↓
Magento Server

In this setup, Magento must correctly understand that the original visitor connection was HTTPS.

Incorrect proxy configuration can cause:

  • Redirect loops
  • Mixed content
  • Incorrect URL generation
  • Repeated HTTPS redirects

Make sure the proxy passes the appropriate HTTPS forwarding information to the Magento server.


14. Use HSTS Carefully

Once HTTPS is fully working, you can consider enabling HTTP Strict Transport Security (HSTS).

A typical header looks like:

Strict-Transport-Security: max-age=31536000

HSTS tells compatible browsers to use HTTPS for future requests.

However, don’t enable aggressive HSTS settings until you are certain that all required subdomains and resources are correctly configured for HTTPS. An incorrect HSTS configuration can make recovery more difficult.


15. Test the Entire Magento Store

After forcing HTTPS, don’t test only the homepage.

Check:

  • Homepage
  • Product pages
  • Category pages
  • Search
  • Customer registration
  • Customer login
  • Cart
  • Checkout
  • Payment methods
  • Shipping
  • Contact forms
  • CMS pages
  • Magento Admin
  • API integrations

Make sure every important function continues working.


Common HTTPS Problems

Redirect Loop

If the browser repeatedly redirects between HTTP and HTTPS, check:

  • Magento secure URL configuration
  • Nginx/Apache redirect rules
  • CDN settings
  • Reverse proxy configuration
  • HTTPS forwarding headers

A proxy that terminates SSL but doesn’t correctly communicate the original protocol to Magento can commonly cause this problem.

Mixed Content Warning

Check your browser’s developer console and identify resources still being loaded through HTTP.

Update hard-coded URLs in themes, CMS content, and extensions.

Admin Panel Not Loading

Verify:

php bin/magento config:show web/secure/use_in_adminhtml

It should return an enabled value.

Also verify that your secure base URL is correct.

Too Many Redirects

Do not configure multiple independent HTTPS redirects at the CDN, web server, and Magento application without understanding how they interact.

Ideally, establish one clear redirect flow:

HTTP request
     ↓
Web server/CDN
     ↓
301 redirect
     ↓
HTTPS Magento URL

Magento HTTPS Checklist

Before considering the migration complete, verify:

  • SSL/TLS certificate is valid
  • Magento Base URL uses HTTPS
  • Secure Base URL uses HTTPS
  • Secure storefront URLs are enabled
  • Secure Admin URLs are enabled
  • HTTP redirects to HTTPS
  • No mixed-content warnings exist
  • Product images use HTTPS
  • CSS and JavaScript use HTTPS
  • Checkout works correctly
  • Payment methods work correctly
  • Admin Panel works correctly
  • CDN/proxy HTTPS configuration is correct
  • Magento cache has been flushed
  • Varnish/CDN cache has been refreshed if applicable
  • HTTPS redirects have been tested

Conclusion

Forcing HTTPS in Magento involves more than installing an SSL certificate. You need to configure Magento’s secure URLs, enable HTTPS for the storefront and Admin Panel, redirect HTTP requests, and eliminate mixed-content problems.

The basic Magento configuration can be handled with:

php bin/magento config:set web/secure/base_url "https://example.com/"
php bin/magento config:set web/secure/use_in_frontend 1
php bin/magento config:set web/secure/use_in_adminhtml 1
php bin/magento cache:flush

Then configure your web server or CDN to permanently redirect HTTP traffic to HTTPS.

Once HTTPS is working correctly across the entire store, consider additional protections such as HSTS, a WAF, strong administrator authentication, and regular security updates.

ByVandeeta
Updated October 06, 2026
  • Magento

Read Next

ByVandeeta
October 6, 2026

How to Protect Magento Admin Login?

How to Protect Magento Admin Login The Magento Admin Panel is one of the most sensitive parts of…
  • Magento
ByVandeeta
October 6, 2026

How to Prevent Magento Brute-Force Attacks?

How to Prevent Magento Brute-Force Attacks Magento stores are frequent targets for automated login attacks because attackers can…
  • Magento
ByVandeeta
October 6, 2026

How to Install Magento Security Updates?

How to Install Magento Security Updates Keeping Magento updated is one of the most important tasks for protecting…
  • Magento

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Explore Categories

  • Control Panels 7
  • Magento 52
  • Miscellaneous 5
  • SEO 17
  • Technology 10
  • Trends 9
  • Web Hosting 7
  • Wordpress 100

Recent Posts

  • How to Fix WordPress “Too Many Redirects”
  • How to Fix WordPress Critical Error
  • How to Fix WordPress Database Connection Error
  • How to Fix WordPress White Screen of Death
  • How to Fix WordPress 404 Error

Recent Comments

  1. Tabias H. on The Future is 5G: Understanding the Next Wave of Connectivity
  2. Elliot Alderson on Evolving Workspaces: The Rise of the Hybrid Work Trend
  3. James Mann on Evolving Workspaces: The Rise of the Hybrid Work Trend
Swyft

Welcome to the Ehostpiya Blog, your trusted resource for web hosting, WordPress, VPS, domains, website security, and online business tips.

Our goal is to make web hosting and website management easier to understand for everyone—from beginners launching their first website to experienced developers and business owners. We publish practical guides, hosting tips, tutorials, and helpful insights to help you build, manage, and grow your website successfully.

At Ehostpiya, we believe that reliable information and quality hosting go hand in hand. Explore our latest articles and discover simple solutions for a faster, safer, and more successful online presence.

  • Facebook
  • Twitter
  • Instagram
  • Pinteres

Featured Posts

  • AI and Ethics: Navigating the Complex Landscape of Artificial Intelligence
    by Vandeeta
    October 11, 2023
  • AR and VR: Blurring the Lines Between Reality and Virtuality
    by Vandeeta
    October 11, 2023
  • Best WordPress Caching Plugins to Improve Website Speed
    by Vandeeta
    September 26, 2026
  • Blockchain Unchained: How Distributed Ledger Technology is Transforming Industries
    by Vandeeta
    October 11, 2023

Web Hosting Discount

cLAIM NOW
logo

Ehostpiya is reliable Web hosting provider, with aim to provide affordable Website and application hosting to various clients for their online business and presence.

Hosting
  • Web Hosting
  • Cloud VPS
  • Reseller Hosting
  • Email Hosting
  • Dedicated Server
  • Nodejs Hosting
  • SSL Certificate
Legal
  • Accepted Uses Policy
  • privacy Policy
  • Terms of Service
  • Refund and cancellation
  • Service Delivery Policy
Company
  • About Us
  • Our Clients
  • Contact Us
  • Our Blog
Support & Tools
  • Open Support Request
  • View Ticket
  • Knowledge Base
  • Report Abuse
  • check nameserver
  • What is my IP
  • Mx lookup

© Ehostpiya, All rights reserved

  • Terms & Condition
  • Privacy Policy