Force HTTPS But Not For Add-On Domain

Setting up a new add-on domain* for a client today and found that I could not access the new add-on domain name directly. It was appending the new add-on domain name to the root or main site url. So instead of taking the visitor to www.newdomain.com it was taking them to www.maindomain.com/newdomain.com, and of course I didn’t want the visitor to see that horrible URL, but only to see the new add-on domain name.

What was happening is there was an HTTPS redirect for all pages on the main site in the .htaccess file. The .htaccess rule was saying, “ANY page visited on the site, redirect to a hard-coded URL of HTTPS, for that page.”

This is what the rule looked like initially:

I needed an .htaccess rule that forced HTTPS on the main site, but left the add-on domain alone to do it’s own thing. Here’s the rule that solved the issue:

For the new .htaccess code replace yourdomain.com on line 7 with your domain. On lines 5 and 6, replace yourdomain\.com while remembering to insert the backslash before the period in your domain name.

Important: If you have existing code in your “.htaccess,” add this above where there are already rules with a similar starting prefix.

 


* An addon domain is a fully functional domain that can be created from within your control panel. Think of it as having multiple hosting packages all sharing the same control panel. You can create email addresses, forwarders and more — the same way you do for your primary domain on the account.

Tags: , ,

Leave a Reply

Other tags used in my blog:

 (1)  (6)  (1)  (16)  (1)  (1)  (17)  (1)  (17)  (1)  (1)  (7)  (1)  (4)  (15)  (5)  (2)  (28)  (9)  (1)  (12)  (4)  (1)  (4)  (5)  (9)  (1)  (6)  (1)  (4)  (1)  (1)  (1)  (3)  (1)  (3)  (4)  (7)  (3)  (3)  (4)  (1)  (1)  (2)  (1)  (7)  (11)  (12)  (2)  (6)  (1)  (3)  (16)  (2)  (3)  (1)  (5)  (1)  (28)  (4)  (4)  (9)