samedi 6 janvier 2018

Redirect www and http to non-www with https using .htaccess

I've got the following written into my .htaccess file which is placed in the directory where my index.html is.

RewriteEngine On                              
RewriteCond %{HTTPS} off                        
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.*)$ [NC]                 
RewriteRule (.*) https://%1%{REQUEST_URL} [L,R=301]

I want that 
www.example.com       
http://example.com    
and http://www.example.com      

are redirected to 
https://example.com

Do I have to exchange REQUEST_URI with example.com or am I doing something else wrong ?

Aucun commentaire:

Enregistrer un commentaire