Lydon
Lydon

Reputation: 1

.htaccess HTTPS main domain and force HTTP on add-on domain

I'm on a shared hosting plan having 1 main domain and 1 add-on domain. I just installed SSL certificate, however, I encountred the following problem

HTTPS on main domain works fine, but when accessing the addon domain I'm getting redirected to another site with HTTPS. I'm able to access the addon domain without HTTP but would it be possible to force HTTPS to HTTP or remove access to HTTPS for the add-on domain?

This is what I currently have in .htaccess

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Upvotes: 0

Views: 431

Answers (1)

Croises
Croises

Reputation: 18671

Without the add-on domain. Use (instead of your code):

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !addondomain\.com$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Force HTTPS to HTTP for the add-on domain. Add:

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} addondomain\.com$ [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Upvotes: 1

Related Questions