PrestaShop: Enable Cloudflare Flexible SSL
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: https://github.com/PrestaShop/PrestaShop/blob/1.6/classes/Tools.php#L269
To solve this:
STEP 1: Complete the cloudflare setup for you prestashop website.
STEP 2: Enable cloudflare Flexible SSL as mentioned here https://support.cloudflare.com/hc/en-us/articles/200170416-What-do-the-SSL-options-Off-Flexible-SSL-Full-SSL-Full-SSL-Strict-mean-
Do not indulge in CloudFlare page rules, it's good to go. Add a pagerule for your website, something like "*.yourwebsite.com/*" 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/settings.inc.php and edit the following line towards the end:
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!