4
I cannot in any way test whether my address is in https when Let’s Encrypt is installed...
Some charitable soul could help me redirect to https?
I have installed in my hosting Uolhost (Platform: Linux, Apache: Version 2.4) the Let’s Encrypt... And I don’t know if there is any direct relationship (I’m still starting my life in programming and know very little of English) between the command:
Rewritecond %{HTTPS} off And the validation Let’s Encrypt... I believe it should be something related to the type of validation that is being done by Encrypt that prevents the Rewritecond command from checking the host...
Currently it is so my . htaccess
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
Options -Indexes
Options +FollowSymLinks
ErrorDocument 400 /redirects/400.html
ErrorDocument 401 /redirects/401.html
ErrorDocument 403 /redirects/403.html
ErrorDocument 404 /redirects/404.html
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
#Tentativas RewriteCond %{HTTPS} (FALHA TUDO QUE TENTEI)
RewriteCond %{HTTP_HOST} ^exemplo\.com\.br [NC] #verifica se falta www (MENOR IDEIA DO PQ DO NC)
RewriteRule ^(.*)$ https://www.exemplo.com.br/$1 [R=301,L] #301 Moved Permanently
#Atualmente consegue redirecionar de exemplo.com.br para https://www.exemplo.com.br
</IfModule>
I tried to set up:
RewriteCond %{HTTPS} off [OR] #não funcionou
RewriteCond %{HTTPS} =off [OR] #não funcionou
RewriteCond %{SERVER_PORT} 80 [OR] #não funcionou
RewriteCond %{SERVER_PORT} =80 [OR] #não funcionou
RewriteCond %{HTTP_HOST} ^exemplo\.com\.br [NC]
RewriteRule ^(.*)$ https://www.exemplo.com.br/$1 [R=301,L]
always returns the error:
"This page is not working
Excessive redirection by www.exemplo.com.br
Try to clear the cookies.
ERR_TOO_MANY_REDIRECTS"
(BS.: ) I put my theory to the test and uninstalled Let’s Encrypt...
RewriteCond %{HTTPS} =off [OR] #funcionou
RewriteCond %{SERVER_PORT} =80 [OR] #funcionou
Redirecting worked but obviously it doesn’t solve my problem because I don’t have a certificate without Let’s Encrypt installed.
The problem is in the process of validating Let’s Encrypt... I need to find another way to redirect, maybe without using Rewriterule.
Another discussion of the same topic
https://cursos.alura.com.br/forum/topico-redirecionar-http-https-com-htaccess-39055
This ERR_TOO_MANY_REDIRECTS is suspicious, do the following, try in this way https://answall.com/a/184459/3635 and let me know what the result is, note, open the browser test window anonymously.
– Guilherme Nascimento
Good evening @Guilhermenascimento. Incredibly, your answer was one of the first I looked at and tried. It doesn’t work... when I inspect what happens is that it redirects infinitely, in a kind of "loop" 301 to https://www.exemplo.com.br... As I said, "Rewritecond" cannot check if it is on "https" when I install Let’s Encrypt ps.: sorry for the delay, I was having dinner
– RoxVision
There must be something you have added to more or some other . htaccess in another folder.
– Guilherme Nascimento
I just checked.. There is no other .htaccess... This behavior does not exist when I give up Let’s Encrypt. Normal redirect
– RoxVision
You installed Let’s Encrypt on your server or localhost (I don’t even know if it’s possible)?
– Guilherme Nascimento
I installed in my hosting uolhost.. the process eh automated.. just click install and ready, the certificate comes to work (valid for 3 months)
– RoxVision
It may be something uolhost is programmed to redirect, I will try to install the certificate on a server to see if it occurs, when I can warn you
– Guilherme Nascimento
Thank you very much! Just emphasizing that the problem occurs specifically when I test "Rewritecond %{SERVER_PORT} =80" (or something like that)... removing this line from htaccess, normally redirects the typed domain without www to www
– RoxVision
I don’t think there’s much point checking the door, it would only be necessary to get the protocol, it must be something else the problem.
– Guilherme Nascimento
so when I test the protocol also enters the loop, I tested both via port and protocol
– RoxVision