http redirect to https via . htaccess - Godaddy

Asked

Viewed 383 times

1

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

support told me that I have to change the file . htaccess and redirect to https, but I already searched several ways and none worked.

I use such Business Hosting ( North America ) dedicated

I tried this code below , but the SSL padlock turns green and then gets no 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]
  • Removes the <IfModule mod_rewrite.c> and the </IfModule> and see if Error 500 occurs.

  • I edited the answer, the reason the green lock does not appear this explained in "Why the green lock still doesn’t appear?"

  • Tell me why the lock stopped popping out of nowhere ?

  • Stop appearing out of nowhere because the images use lazyload, ie only load after the full page is loaded, out which template is dynamic and not static, ie it is all loaded via ajax requests and DOM manipulation. As I said, the console shows the error "Mixed content", just press F12. If your page is HTTPS and you put an HTTP image inside it it breaks the security and therefore the lock disappears, because it is not safe.

2 answers

2

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]
  • did not work =/ I did as you said . I will change the question as I put.

  • Oops !! the green lock came up, but then it went away - can you tell me why ? @Deboracristina

1


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

Now let’s go to error, you used:

{REQUEST_URI}

When the correct is:

%{REQUEST_URI}

Thus remaining:

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

One suggestion I make is to do as I did in this reply /a/207031/3635, wear like this:

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

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

If you want to add the www also, if the user type 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 the green lock still doesn’t appear?

This is because you have Resources, as images inside gives page on the HTTP protocol instead of HTTPS, so 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, music, 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 safe everything has to use the HTTPS protocol.

  • I’ll look here and if that’s what you’re saying I confirm ...just for a moment

  • @jhonatansantos just press F12 (if it is the Chrome browser) you will see a dozen errors written "Mixed Content".

  • I noticed that if I type www.pipocaplayfm.com.br it does not direct to https ...but if I type with https before it will show the green lock.... know why that man ?

  • @jhonatansantos here is directing normal. It must be the browser that omits the protocol in the prefix.

  • 1

    It was td right !! vlw

Browser other questions tagged

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