htaccess need to redirect the main domain but not addon domains

I know nothing about htaccess more than talking to support today and them telling me I need to use it to fix my issue.

Long story short…I have a main domain on a cPanel that is a wordpress eCommerce site. I bought and set up an SSL certificate for it. I also have 4 addon sites setup that are just plain html. The SSL doesn’t work on them. (I don’t know why, they said the type of ssl only works on the main site).

Read More

In the wordPress eCommerce Site, I had a plugin forcing a redirect to https version of the site. It did that by modifying the .htaccess file. BUT, it modifies it in a way that all the addon sites get redirected to https too. They then show a message saying that they are not safe and get me out of here and so on… not good!

So my question is how can a write an .htaccess file so only the main site gets redirected to an https version and not the addons?

example sites:

mymainsite.com -> https://mymainsite.com 
myaddonsite1.com -> no redirect
myaddonsite2.com -> no redirect

Related posts

1 comment

  1. To redirect mainsite to https, you can use :

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^(www.)?mainsite.com$
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
    

    Just replace mainsite.com with your domainname.com in the http_host value.

Comments are closed.