Answer the question
In order to leave comments, you need to log in
How to set redirect to https in .htaccess?
Good afternoon. I'm trying to redirect a site from:
site.com
www.site.com
http
to https://site.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.site.com $ [NC]
RewriteCond %{HTTP_HOST} ^site.com
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://site.com/$1 [R=301,L]
Answer the question
In order to leave comments, you need to log in
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question