My site is not redirected to https

Asked

Viewed 56 times

1

I’m trying to get my website redirected 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

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 prefer everything to go to without www, exchange the last line for:

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

If you prefer to keep the www typed equal, exchange the last line for:

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

Remembering that if you put the certificate in the same IP of the sites SEM certificate, and someone tries to access https://site-sem-certificado.com.br will give error anyway, because the negotiation of SSL comes before Apache process the page.

And that’s why SSL places you in exclusive IP (or if you spend money on certificates for multiple domains).

I got that answer from here

-1

Mine works with that 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

  • I put the same code, simply appears ERR_TOO_MANY_REDIRECTS

  • I copied from my . htaccess in production. Very strange, this is your site same? lotericapremiada.com.br?

  • That, I’ve tried in every way, but to no avail!

  • Rewriteengine on Rewritecond %{HTTPS} ! on [OR] Rewriterule . * https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] Rewritecond %{REQUEST_FILENAME} ! -f Rewritecond %{REQUEST_FILENAME} ! -d Rewritebase /index.php

  • I checked that when access your domain does not run the site, check if the rewrite_module function is enabled in apache. Only then will he respect the rules . htaccess

Browser other questions tagged

You are not signed in. Login or sign up in order to post.