7 steps to fix SSL when it fails on Opencart 22.214.171.124
Back Posted on 23 Mar 2017
Opencart 126.96.36.199 is widely reported to have a number of bugs relating to configuring it to run on a secure SSL connection.
Having experienced this recently I found plenty of others had issues running Opencart 188.8.131.52 in SSL mode including
- admin users being unable to login
- errors installing under SSL
- mixed content warnings from CSS/JS files being served over http
- navigation links pointing to http
Fixes suggested often involve editing core files. This is bad practice as changes to the core will be overwritten during future updates. Instead use VQmod or OCmod to extend or update the core witout editing the original files.
Opencart user andreiwd kindly pulled the fixes required to force Opencart 184.108.40.206 to run securely into VQmod.
Installation + configuration
The VQmod file takes care of the bugs in Opencart 220.127.116.11 so all you need to do is configure opencart
- install an ssl certificate on your server
- update the server urls in Opencart
- enable SSL System > Settings, Edit your store, on the Server tab under Security select Yes for Use SSL
- apply force https for opencart 18.104.22.168 with VQmod
- clear the cache at /system/storage/cache (a necessary step in my case as the navigation menu is written to file and wouldn't pick up url changes automatically)
- add redirect rules to force SSL in your web server config file (.htaccess for Apache, web.config for IIS)
- update any hard coded URLs using http in the database (example sql below)
Updating hard coded URLs
If your Opencart database includes URLs hard coded to http:// you should update them to https://.
Doing this manually by editing pages and products through the admin panel would be painfully slow and error prone. Thankfully there are better options
- Database search and replace script by interconnect/it
- Run updates directly on the databsse
Updating the database directly
You can update your database directly through phpMyAdmin, Heidi or any similar tool. The examples below include some default Opencart tables and a few others relating to specific extensions.
Depending on your setup and extensions you will need to adjust the table names and search/replace strings appropriately.
UPDATE oc_menu SET link = replace(link,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_redirects SET to_url = replace(to_url,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_information_description SET description = replace(description,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_blog_article_description SET description = replace(description,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_product_description SET description = replace(description,'http://www.domain.co.uk','https://www.domain.co.uk');
UPDATE oc_product_tab_content SET content = replace(content,'http://www.domain.co.uk','https://www.domain.co.uk');