Htaccess http vers https

WRInaute accro
Bonjour,

Je sais... je sais... les exemples sur le web de redirections ne manquent pas mais il y a à boire et à manger !
Le dossier de wri n'est pas complet.

J'essaye de faire:
Code:
http://www.monsite.com => https://www.monsite.com
http://monsite.com => https://www.monsite.com
https://monsite.com => https://www.monsite.com

Voilà, ce que j'ai à l'heure actuelle:
Code:
RewriteEngine On
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Tout fonctionne sauf : -https://monsite.com => -https://www.monsite.com

Merci de votre aide
 
WRInaute accro
passion a dit:
Bonjour,

Voilà, ce que j'ai à l'heure actuelle:
Code:
RewriteEngine On
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Tout fonctionne sauf : -https://monsite.com => -https://www.monsite.com

Merci de votre aide

Bonjour

Pourquoi ne pas faire :

Code:
RewriteEngine on
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{HTTP_HOST} ^monsite.com$
RewriteRule ^(.*) https://www.monsite.com/$1 [QSA,L,R=301]

#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
 
Discussions similaires
Haut