Utiliser flexible SSL sur prestashop
Fonctionne avec CloudFlare et Nitrique Concept :
dans config/settings.inc.php :
define('_PS_CLOUDFLARE_SSL', '1');
dans Classes/tools.php :
* Check if the current page use SSL connection on not |
public static function usingSecureMode() |
if (isset($_SERVER['HTTPS'])) |
return in_array(Tools::strtolower($_SERVER['HTTPS']), array(1, 'on')); |
// $_SERVER['SSL'] exists only in some specific configuration |
if (isset($_SERVER['SSL'])) |
return in_array(Tools::strtolower($_SERVER['SSL']), array(1, 'on')); |
// $_SERVER['REDIRECT_HTTPS'] exists only in some specific configuration |
if (isset($_SERVER['REDIRECT_HTTPS'])) |
return in_array(Tools::strtolower($_SERVER['REDIRECT_HTTPS']), array(1, 'on')); |
if (isset($_SERVER['HTTP_SSL'])) |
return in_array(Tools::strtolower($_SERVER['HTTP_SSL']), array(1, 'on')); |
if (_PS_CLOUDFLARE_SSL) { |
}
Une fois ces opérations effectuées, aller dans paramètre -> général, activer ssl, ssl anywhere.
Ensuite pour terminer, ajouter les lignes suivantes au tout début du .htaccess :
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
SetEnvIf X-Forwarded-Proto https HTTPS=on
That's it ! Enjoy ;)