Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix rewrite from http to https in .htaccess

Discussion in 'Misc WordPress Requests' started by toloekka, Jan 27, 2018.

  1. toloekka


    rewrite from http to https in .htaccess, by toloekka


    I run a WordPress Site (4.9.2) and just activated SSL on the Server and the URL is now https://www.norwegianoutfitters.no
    I then found documentation on Internet that I could change the «.htaccess» file to rewrite from http to https.
    I also see in documentation found on Internet that I cannot set «RewriteEngine On» twice in the «.htaccess» file“.

    Here is my «.htaccess» file now after I put in the second part (after # END WordPress):
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    #Rewrite everything to https
    RewriteEngine On
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    The first part in the “.htaccess” must be default from WordPress i think.
    The second part I added because I will force visitors to use https.

    I have also put https (https://www.norwegianoutfitters.no) in Settings > General > WordPress Adress (URL) and the same in Settings > General > Site Adress (URL).

    So my questions is:
    I wonder if «RewriteEngine On» is considered as twice in my «.htaccess», or is it okay?
    If not, what is the right code?

    No I use «RewriteCond %{HTTPS} !=on» but I also find this code to be used, «RewriteCond %{HTTPS} off».
    Which one is right or will both work?

    Or maybe I don’t have to use «rewrite everything to https» in the «.htaccess» file because I have change the URL’s in WordPress Settings?

    I also see this «Connection is Not Secure – Part of this page are not secure (such as images)». when I hover the mouse over the padlock icon. What can I do to fix this?

    Hope someone can help and clarify this.

    Kind Regards
    Tom Løkka

    rewrite from http to https in .htaccess

Share This Page

Monarch Social Sharing Plugin