{"id":19562,"date":"2021-05-19T20:14:00","date_gmt":"2021-05-19T12:14:00","guid":{"rendered":"https:\/\/www.mondoze.com\/guide\/?post_type=kb&p=19562"},"modified":"2022-10-11T17:42:00","modified_gmt":"2022-10-11T09:42:00","slug":"how-to-force-opencart-to-work-with-https","status":"publish","type":"kb","link":"https:\/\/www.mondoze.com\/guide\/kb\/how-to-force-opencart-to-work-with-https","title":{"rendered":"How to force Opencart to work with HTTPS"},"content":{"rendered":"\t\t
This article will talk about running Opencart application with HTTPS\u00a0<\/strong><\/p> For this case we shall use sample domain : opencart.worldfortesting.com<\/p> Webpage without HTTP :<\/p> After SSL installed. If you tried to access the webpage with HTTPS, you might see the application broken as below :<\/p> In order for the Opencart application to work well with HTTPS, some updates have to be done as below :<\/strong><\/p> 1. Set your HTTPS URL in config.php Files<\/p> Before you enable the SSL in your OpenCart admin dashboard, you need to edit the two configuration files of your<\/p> OpenCart<\/p> 2. Both files are called config.php and they are located under the root directory of your OpenCart application and under the admin folder.<\/p> 3. Choose the file and click Code Editor\u00a0<\/strong>to edit the config.php file.<\/p> You need to locate the following section in both of your files:<\/p> \/\/ HTTPS Modify the line to include https instead of http<\/strong>:<\/p> \/\/ HTTPS Sample done as below :<\/p> 4. Enable SSL via the OpenCart Admin<\/p> Now you need to activate the SSL support via the admin dashboard.<\/p> Firstly login to your\u00a0 admin dashboard<\/p> 5. Check the settings part and click “Edit” to edit the store setting<\/p> Proceed to the Server settings tab. And you can see Use SSL option there. Click on the Yes radio button and save your settings.<\/p> 3. Force HTTPS only for your domain name<\/p> a) Create a file name .htaccess in your domain folder, and put in below code (the domain for this case is opencart.worldfortesting.com) :<\/p> ===========<\/p> RewriteEngine On ===========<\/p> b) Open the .htaccess again<\/p> Replace this link as below<\/p> =========<\/p> <FilesMatch “(?i)((\\.tpl|\\.ini|\\.log|(?<!robots)\\.txt))\u201d><\/p> =========<\/p> to link as below<\/p> =========<\/p> <FilesMatch “(?i)((\\.tpl|\\.ini|\\.log))\u201d><\/p> =========<\/p> With above, user accessing to\u00a0http:\/\/opencart.worldfortesting.com\u00a0(without HTTPS) shall be redirected to\u00a0https:\/\/opencart.worldfortesting.com\u00a0which is the page with SSL secured. Below is the screenshot :<\/p> Do update us (support team) if you need assistance on the above settings.<\/p>\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":" How To Force Opencart to Work with HTTPS This article will talk about running Opencart application with HTTPS\u00a0 For this case we shall use sample domain : opencart.worldfortesting.com 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 …<\/p>\n
<\/p>
<\/p>
<\/p>
define(‘HTTPS_SERVER’, ‘http:\/\/yourdomain.com\/’);<\/p>
define(‘HTTPS_SERVER’, ‘https:\/\/yourdomain.com\/’);<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
<\/p>
RewriteCond %{HTTP_HOST} ^opencart.worldfortesting\\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$\u00a0https:\/\/opencart.worldfortesting.com\/$1\u00a0[R,L]<\/p>
<\/p>