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 : 

Webpage without HTTP :

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

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 OpenCart 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.

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:

define('HTTPS_SERVER', '');

Modify the line to include https instead of http:

define('HTTPS_SERVER', '');

Sample done as below :

2. Enable SSL via the OpenCart Admin

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

Firstly login to your Opencart admin dashboard

Check the settings part and click "Edit" to edit the store setting

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

3. 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 :


RewriteEngine On
RewriteCond %{HTTP_HOST} ^opencart.worldfortesting\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$$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 (without HTTPS) shall be redirected to which is the page with SSL secured. Below is the screenshot :

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

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.