Mondoze Knowledge Base

Search our articles or browse by category below

How to force Opencart to work with HTTPS

Last modified: October 11, 2022
You are here:
Estimated reading time: 1 min

How To Force Opencart to Work with HTTPS

This article will talk about running Opencart application with HTTPS 

For this case we shall use sample domain : opencart.worldfortesting.com

Webpage without HTTP :

Webpage without HTTP

After SSL installed. If you tried to access the webpage with HTTPS, you might see the application broken as below :

webpage with HTTPS

In order for the Opencart application to work well with HTTPS, some updates have to be done as below :

1. Set your HTTPS URL in config.php Files

Before you enable the SSL in your OpenCart admin dashboard, you need to edit the two configuration files of your

OpenCart

2. Both files are called config.php and they are located under the root directory of your OpenCart application and under the admin folder.

openCart config file

3. Choose the file and click Code Editor to edit the config.php file.

You need to locate the following section in both of your files:

// HTTPS
define(‘HTTPS_SERVER’, ‘http://yourdomain.com/’);

Modify the line to include https instead of http:

// HTTPS
define(‘HTTPS_SERVER’, ‘https://yourdomain.com/’);

Sample done as below :

code editor

4. Enable SSL via the OpenCart Admin

Now you need to activate the SSL support via the admin dashboard.

Firstly login to your  admin dashboard

openCart login

5. Check the settings part and click “Edit” to edit the store setting

dashboard settings

Proceed to the Server settings tab. And you can see Use SSL option there. Click on the Yes radio button and save your settings.

server tab and SSL option

6. Force HTTPS only for your domain name

a) Create a file name .htaccess in your domain folder, and put in below code (the domain for this case is opencart.worldfortesting.com) :

modify .htaccess

===========

RewriteEngine On
RewriteCond %{HTTP_HOST} ^opencart.worldfortesting\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://opencart.worldfortesting.com/$1 [R,L]

===========

b) Open the .htaccess again

Replace this link as below

=========

<FilesMatch “(?i)((\.tpl|\.ini|\.log|(?<!robots)\.txt))”>

=========

to link as below

=========

<FilesMatch “(?i)((\.tpl|\.ini|\.log))”>

=========

With above, user accessing to http://opencart.worldfortesting.com (without HTTPS) shall be redirected to https://opencart.worldfortesting.com which is the page with SSL secured. Below is the screenshot :

page with SSL secured

Do update us (support team) if you need assistance on the above settings.

Was this article helpful?
Dislike 0
Views: 74