I have godaddy hosting and I am using it to host multiple domains. With this hosting I got a free standard (One domain) SSL certificate. I set it up on my primary domain and all is good, https://www.primarydomain.com works. Also my secondary sites still work with the regular http.
(Also just so you know, most browsers tell me to go back, bad site, might harm computer, etc when I go to https://secondarydomain.com because the certificate is only for the primary.)
So what I am trying to do is when the user goes to my primary site, the htaccess automatically changes to the https using this code:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
That works and all is good, but because the secondary domains get their content form directories of the first domain, the .htaccess affects all domains I have, thus trying to add https to my secondary domain. (Tells user to leave site)
How would I tell .htaccess to change to https only when on my primary domain and to just leave it alone with the http for my secondary domains?
If you don’t know what the heck I am saying, you can see how right away my primary domain changes to https: http://www.alexkafer.com
Then one of my secondary domains: http://www.codingapple.com also tries to change to https, even though it is not made for that domain.
I promise my secondary is not going to harm your computer, it is just the certificate is not for the domain codingapple.com That is what I am trying to fix.
Thank you @Scott S for your code. It worked prefect, except it did the oposite that I wanted.
The above code changed every secondary domain to HTTPS instead of the primary to HTTPS.
I removed the ! before the ^(127.0.0.1|localhost)$ and now it is doing what I need!