Answer the question
In order to leave comments, you need to log in
Redirects from http to https?
Hi everybody. Problem following, the certificate on a site is bought. You need to configure the correct redirect from http to https. At the moment, the code is registered in .htaccess:
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Answer the question
In order to leave comments, you need to log in
#First rewrite any request to the wrong domain to use the correct one (here www.)
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) http://%{HTTP_HOST}:443/$1 [L,R]
#Now, rewrite to HTTPS:
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) http://%{HTTP_HOST}:443/$1 [L,R]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question