0

I am using a wildcard SSL on my main domain and a few sub-domains (apps, dashboard, support, training). The problem I am facing is that when I try to access a sub-domain via HTTPS, it shows the index/main page of the root domain, but when the sub-domain is accessed via HTTP, it shows the correct page. I would like to know what information I would need to put in the .htaccess file to make the sub-domains:

  1. Automatically use HTTPS.
  2. Show the correct content on that sub-domain when using HTTPS.

The sub-domains don't currently have an .htaccess file, because I have no idea what should be put in there at this point.

Here is an example of the HTTP sub-domain: http://goo.gl/Mcg66l
Here is an example of the HTTPS sub-domain: http://goo.gl/Aw9yl6
Here is the main domain: http://goo.gl/TfLjuy

The main domain is doing exactly what I want it to do (www to non-www and automatic https redirection), but the sub-domains are not doing what I want them to do, as described above.

Here is the .htaccess file on the main domain:

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

Lastly, I am using cPanel under a reseller account serviced by HostGator.

Thanks for taking a look at this problem!

alexhoug
  • 195
  • 2
  • 2
  • 7

1 Answers1

0

I had the same exact issue, also using a HostGator account. I found the answer on another question that you can find here.

They go about solving it by applying HTTPS for the main domain, forcing HTTP on a subdomain, and then as a bonus remove all WWW's

# for main domain
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ https://domain.com%{REQUEST_URI} [R=301,L,NE]

# for sub domain
RewriteCond %{HTTP_HOST} ^(www\.)?subdomain\.domain\.com$ [NC]
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule ^ http://subdomain.domain.com%{REQUEST_URI} [R=301,L,NE]
Community
  • 1
  • 1