My site is not redirected to https [duplicate]

1

I'm trying to make my site redirect to htpss, but I'm not getting it.

Below is the code in htaccess

RewriteEngine On
RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://www.lotericapremiada.com.br%{REQUEST_URI} [R=301,L]
RewriteBase /index.php
    
asked by anonymous 31.01.2018 / 19:32

2 answers

0

This is a very simple alternative:

RewriteEngine On 
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^.*$ https://www.domain.com%{REQUEST_URI} [R,L]

If you want everything to go to www without www, change the last line to:

RewriteRule ^.*$ https://domain.com%{REQUEST_URI} [R,L]

If you prefer to keep www as typed, change the last line to:

RewriteRule ^.*$ https://%1domain.com%{REQUEST_URI} [R,L]

Remembering that if you put the certificate in the same IP of the sites WITHOUT a certificate, and someone trying to access link will give error anyway, because SSL negotiation comes before Apache processes the page.

And that's why SSL-enabled site puts itself in exclusive IP (or if you spend money on certificates for multiple domains).

I took this response from here

    
31.01.2018 / 21:07
-1

Mine works with this code

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d

Good luck

    
31.01.2018 / 19:39