PrestaShop: Enable Cloudflare Flexible SSL

Nishant Arora 23/Dec/2014

I guess everyone knows about the Cloudflare's flexible SSL, which is free and can be enabled for all sites served using CF's CDN network. Like this blog itself is being served over the CF network and has the Flexible SSL enabled. However just enabling the SSL/page rule thingy will not solve all your problems. Like my blog which uses wordpress didn't work properly in the first go. I had to redo some portions of the theme (mostly regex edits) to support the new secure urls. Currently it uses a tweaked mod_rewrite + page rules to force SSL everywhere.

Wordpress was easy, but currently I am working with PrestaShop for someone and enabling flexible SSL seems painful. I could maybe workout a patch and ask the team if they feel like pulling it to their core repository. I am not sure if this can be done using a prestashop module. However, I can give you a quick fix for the problem.

The problem is, PrestaShop's design, it doesn't supports flexible/shared/server SSL certificates by default. It wants your system to have a dedicated SSL installed. Here is the problematic class:

To solve this:

STEP 1: Complete the cloudflare setup for you prestashop website.

STEP 2: Enable cloudflare Flexible SSL as mentioned here

STEP 3: Do not indulge in CloudFlare page rules, it's good to go. Add a pagerule for your website, something like "**" with https always enabled, It will help!

STEP 4: Login to phpMyAdmin for your server. Locate table 'ps_configuration', find rows with names "PS_SSL_ENABLED" and "PS_SSL_ENABLED_EVERYWHERE" edit their values to be 1, earlier it was 0.

STEP 5: Use your favourite FTP client to get to your site root, and use your favourite editor to edit the following files.

Edit: public_html/config/ and edit the following line towards the end:

define('_PS_CLOUDFLARE_SSL', '1');

Edit: public_html/classes/Tools.php and change the following function:

That should be it, your site should be fully functioning with free SSL enabled, thanks to cloudflare!