How do I configure HTTPS for my Magento store?
Configure HTTPS for Magento 2.4.7
Step 1: Obtain an SSL Certificate
Purchase an SSL Certificate:
Obtain an SSL certificate from a trusted Certificate Authority (CA) like Let's Encrypt, Comodo, DigiCert, or any other provider.
Install the SSL Certificate:
Install the SSL certificate on your web server. Consult your hosting provider's documentation for specific instructions.
Step 2: Configure Magento to Use HTTPS
Log in to Your Magento Admin Panel:
Navigate to your Magento admin URL and log in with your admin credentials.
Navigate to the Web Configuration:
Go to Stores > Configuration > General > Web
.
Configure Base URLs:
Expand the Base URLs
section and update the Base URL
to use HTTPS.
Configure Secure Base URLs:
Expand the Base URLs (Secure)
section and update the Secure Base URL
to use HTTPS.
Set Secure URL Options:
In the Base URLs (Secure)
section, set Use Secure URLs on Storefront
to "Yes".
Set Use Secure URLs in Admin
to "Yes".
Save Configurations:
Click on the Save Config
button at the top right to apply the changes.
Step 3: Update the env.php
Configuration File
Access Your Magento Root Directory:
Use FTP/SFTP or SSH to access your Magento root directory.
Edit the env.php
File:
Open the app/etc/env.php
file in a text editor.
Add the Secure URLs Configuration:
'http' => [
'host' => 'www.yourdomain.com',
'use_frontend_secure' => true,
'use_admin_secure' => true
]
Save and Close the File:
Save the changes and close the file.
Step 4: Clear Cache and Reindex
Clear Cache:
Navigate to System > Cache Management
in the admin panel and click on Flush Magento Cache
.
Alternatively, you can clear the cache using the command line:
php bin/magento cache:clean
php bin/magento cache:flush
Reindex Data:
Reindex the data using the command line:
php bin/magento indexer:reindex
Step 5: Test Your Store
Verify HTTPS Configuration:
Open your web browser and navigate to your Magento store.
Ensure that the URL starts with https://
and that the browser displays a secure padlock icon.
Check for Mixed Content:
Use browser developer tools to check for any mixed content warnings. Mixed content occurs when a webpage is loaded over HTTPS, but other resources (images, scripts, etc.) are loaded over HTTP.