Reputation: 143
how can i write my htaccess file to check which domain is being requested and then either force https or force http depending which domain is being requested (my godaddy (i know, i know) hosting plan has a primary domain and multiple addon domains which point to directories in the main domain's public_html folder)?
if user requests http://secure.com then force it to be https
if user requests https://nonsecure.com then force it to be http
basically, how can we force https or http based on which domain is being requested.
Upvotes: 0
Views: 1146
Reputation: 143906
Make sure you have mod_rewrite loaded and add these rules to the document root of both "secure" and "nonsecure" websites:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^secure\.com$ [NC]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
RewriteCond %{HTTP_HOST} ^nonsecure\.com$ [NC]
RewriteCond %{HTTPS} on
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R]
Upvotes: 1