Http redirect to https via .htaccess - Godaddy

0

I have signed an SSL certificate, installed the certificate, but my site does not appear on https.

Support told me that I have to change the .Htaccess file and redirect to https, but I already researched several ways and none worked.

I use such dedicated (North America) Business Hosting

I tried this code below, but the SSL lock is green and then runs out of color.

RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

RewriteCond %{HTTPS} off
RewriteRule ^ https://www.nomedosite.com.br%{REQUEST_URI} [R=301,L]
    
asked by anonymous 18.01.2018 / 19:41

2 answers

1

First remove the <IfModule mod_rewrite.c> and </IfModule> and see if 500 occurs, if it is because your server does not support the module, then ask the support that activates it.

Now let's go to the error, you used:

{REQUEST_URI}

When the correct one is :

%{REQUEST_URI}

Looking like this:

RewriteCond %{HTTPS} off
RewriteRule ^ https://www.pipocaplayfm.com.br%{REQUEST_URI} [R=301,L]

One suggestion I make is to do the same thing I did in this response link , use this:

RewriteCond %{HTTPS} off
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Because if you change the domain name htaccess will still work.

If you want to add www also, if the user types without, then do so:

RewriteEngine On

# Redireciona para o HTTPS independente do domínio
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Adiciona www. no prefixo do domínio
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Rotas
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Why does not the green lock still appear?

This is because you have resources such as images inside gives page over HTTP protocol rather than HTTPS, so much so that if you open the console you will see several messages like this:

Mixed Content: The page at 'https://www.pipocaplayfm.com.br/' was
loaded over HTTPS, but requested an insecure image 'http://www.pipocaplay
fm.com.br/assets/images/genres/sertanejo-universitario.jpg'. This content should
also be served over HTTPS.

That is, you have to fix the images, videos, songs, Javascripts, css and etc. for HTTPS as well.

See for example the icon is still in HTTP:

<link rel="icon" type="image/x-icon" href="http://www.pipocaplayfm.com.br/storage/branding_images/DyATnJFk03RxUUwDXcyyIjEGN1x81TMtlVUrtwfN.jpeg">

And your images too:

<div class="img-container">
    <img class="lazy-loaded ng-lazyloaded" src="http://www.pipocaplayfm.com.br/assets/images/genres/velha-guarda.jpg">
</div>

To be truly secure, everything has to use the HTTPS protocol.

    
18.01.2018 / 21:16
1

Try adding the following line to your .htaccess (giving a blank line after the line

RewriteRule ^(.*)$ public/$1 [L]

 RewriteCond %{HTTPS} off
 RewriteRule ^ https://www.seudominio.com{REQUEST_URI} [R=301,L]
    
18.01.2018 / 20:16