Aller au contenu principal

Pop up

Drupal 10, rediriger les requêtes http vers https

La redirection des requêtes non sécurisé (http) vers https peut se faire de differente facon. Nous vous proposons une approche simple via le fichier .htaccess

Vous devez ajouter le code suivant dans le fichier .htaccess
 

   # NEW CODE HERE #
   RewriteCond %{HTTPS} off
   RewriteCond %{HTTP:X-Forwarded-Proto} !https
   RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
   # END NEW CODE #
Votre fichier devrait ressembler à :
...
# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on
  
   # NEW CODE HERE #
   RewriteCond %{HTTPS} off
   RewriteCond %{HTTP:X-Forwarded-Proto} !https
   RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
   # END NEW CODE #

  # Set "protossl" to "s" if we were accessed via https://.  This is used later
  # if you enable "www." stripping or enforcement, in order to ensure that
  # you don't bounce between http and https.
  RewriteRule ^ - [E=protossl]
  RewriteCond %{HTTPS} on
  RewriteRule ^ - [E=protossl:s]

  # Make sure Authorization HTTP header is available to PHP
  # even when running as CGI or FastCGI.
  RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
...
Stephane K

Écrit le

Il y'a 5 months
Modifié
Il y'a 5 months
Loading ...