• Hi,

    I purchased ssl from my host (hostgator) and it’s paid and setup.

    I went through my wordpress dashboard >> settings and changed the urls to https. I also modified any plugins to use https.

    My question is I want to redirect everyone to https://www version (not the non ww) should I add these to .htaccess?

    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mydomain.com$
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator bcworkz

    (@bcworkz)

    If you are on an Apache server, then yes. One small correction, change the last line’s http: to https:. Might as well avoid another rewrite.

    Thread Starter Jack Sarlo

    (@redhalls)

    Thank You.

    Thread Starter Jack Sarlo

    (@redhalls)

    I actually forgot one thing.

    What code do I use to redirect from https://website.com to https://www.website.com and do I add it after this code or instead of some parts of it:

    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]
    
    RewriteCond %{HTTP_HOST} ^mydomain.com$
    RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

    Do I use this one instead of the other one:

    RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
    RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]

    Thanks

    • This reply was modified 6 years, 10 months ago by Jack Sarlo.
    • This reply was modified 6 years, 10 months ago by Jack Sarlo.
    Moderator bcworkz

    (@bcworkz)

    I’d use the first set. The second part of the first rewrites mydomain.com to https://www.mydomain.com. Change the last line to use https though, then the order doesn’t matter too much as long as it’s before the WP rewrites.

    Thread Starter Jack Sarlo

    (@redhalls)

    alright but when I go to https://mysite.com it’s showing certificate error, it’s not redirecting to https://www.mysite.com.

    The ssl I purchased is on https://www.mysite.com

    This is the site: https://straighttalkperfectsalesletter.com/

    Thanks

    • This reply was modified 6 years, 10 months ago by Jack Sarlo.
    Moderator bcworkz

    (@bcworkz)

    I see. The browser triggers the warning before the redirect is able to take place. If one allowed an exception, the redirect then does indeed take place, so your rule is correct, but it’s too little too late.

    A site I have also has a www common name certificate. Requesting without the www does not trigger the browser warning. Unfortunately, I do not know the specifics of the certificate, the host managed obtaining the certificate for us. Some how it works, but I could not tell you why. The site does not even have a no-www to www redirect .htaccess rule, that redirect is done by WP because the siteurl option has www. So somehow a non www request is allowed through despite the certificate’s common name having the www.

    Perhaps your host could suggest what the problem may be? This issue is a little outside of WP, as it happens before WP is even involved.

    Thread Starter Jack Sarlo

    (@redhalls)

    I’ll contact them, the 24th time I think :).

    Thanks for helping.

    Thread Starter Jack Sarlo

    (@redhalls)

    The basically said I have to buy ssl for the non www too.

    I just figured a positive ssl from namecheap covers both www and non www. About $70 + $50 installation for 7 websites instead of $400 with a multi site ssl.

    This code will redirect all to https:

    RewriteCond %{HTTPS} !=on [OR]
    RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘About setting up SSL’ is closed to new replies.