• Hi 🙂

    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]
    </IfModule>

    # 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:
    1)
    I wonder if «RewriteEngine On» is considered as twice in my «.htaccess», or is it okay?
    If not, what is the right code?

    2)
    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?

    3)
    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?

    4)
    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

    • This topic was modified 8 years, 4 months ago by toloekka.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • You should combine the rewrite blocks, try:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    #Rewrite everything to https
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    #the usual WordPress settings
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    Thread Starter toloekka

    (@toloekka)

    Hi and thanks for answering 🙂

    I got this error when trying your code:
    Internal Server Error
    The server encountered an internal error or misconfiguration and was unable to complete your request.

    So I changed it back.

    Thread Starter toloekka

    (@toloekka)

    I noticed that the padlock in front of the URL changed to green when trying your code, but sadly I got the “Internal Server Error”.

    Thread Starter toloekka

    (@toloekka)

    Hi again.

    I checked the Site with this https://www.whynopadlock.com/ and found the images that used http. I inserted those images again and the padlock is now green.

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

    of the .htaccess because it seems to be that this part/block did not take effect at all.

    So now I think all is okay (not sure thow) and that I don’t need to rewrite from http to https.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘rewrite from http to https in .htaccess’ is closed to new replies.