If the subdomain points to a subdirectory off the main domain's document root then you can simply include a RewriteEngine On
directive in that subdirectory's .htaccess
file. However, this will override all the mod_rewrite directives in the parent .htaccess
file, which may not be desirable (although "other config from the parent domain" will be inherited).
If you have other mod_rewrite directives in the parent .htaccess
that you do want to run then you will need to add a condition to this HTTP to HTTPS rule in the parent .htaccess
file that specifically excludes the subdomain.
For example:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^subdomain\.
RewriteCond %{HTTPS} !on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
Which says... if the host does not start subdomain.
and is not https then...
You normally require the L
flag on redirects so processing does not continue through the file (if you have more mod_rewrite directives). Also, this shopuld normally be a 301 (permanent) redirect. If this is the case then change the 302
to 301
when you are sure it's working OK. Although maybe best left as a 302 whilst this is being developed.
Also, no need to capture the URL-path (ie. (.*)
) if this is not being used in the RewriteRule
substitution (or RewriteCond
directives).