Jan 5, 2012
14
1
53
India
cPanel Access Level
Root Administrator
Twitter
I own multiple domain names under single main domain as addon domain .,
i also bought ssl for main domain .
to force all non ssl to ssl i use following .htaccess code

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^$ https://www.maindomain.com/$1 [R,L]

this works fine ., but the issue is if i enter addondomain.info it also redirects to https://www.maindomain.com/addondomain.info/ .

i want only main domain to do https redirection how to do it ???

Note : if i enter www.addondomain.info instead of simply addondomain.info it works fine
 
Jan 5, 2012
14
1
53
India
cPanel Access Level
Root Administrator
Twitter
I found the solution as follows :

Add another condition to it:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?maindomain\.com$ [NC]
RewriteRule ^$ https://www.maindomain.com/$1 [R,L]
Also, you'll want to place this at the very top of your htaccess file so that it gets applied before any other rules.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,913
2,201
363
Hello :)

You may also want to consider installing separate SSL certificates for each addon domain name. It's possible to install multiple certificates for domain names on the same account and IP address assuming your system supports SNI (CentOS 6 or RHEL 6 and cPanel version 11.38 or higher).

Thank you.