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
*
* @return bool uses SSL
*/
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'));
// Cloud flare hack
if (_PS_CLOUDFLARE_SSL) {
return true;
}
return false;

}

 

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 ;)

 

Détails de l'Article

Article ID:
57
Catégorie:
Date:
10/03/2017 09:32:58
Affichage:
1.579
Evaluer (Voter):
(24)

Articles en rapport