: How do I prevent a rewrite rule from executing for just one subdomain? In the root level .htaccess I have added a condition to rewrite HTTP requests as HTTPS: RewriteEngine On RewriteCond %{HTTPS}
In the root level .htaccess I have added a condition to rewrite HTTP requests as HTTPS:
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI}
This applies to the main domain and all subdomains. Unfortunately there is still work to do in one of the subdomains in order for it to work with HTTPS, so I would like to insert something into that one's .htaccess file to undo the inherited rewrite rules.
The file must still inherit a lot of other config from the parent domain, so it must only undo that one rewrite rule.
How can I disable this rewrite rule for a particular subdomain?
More posts by @Frith620
1 Comments
Sorted by latest first Latest Oldest Best
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 ^ %{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).
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2025 All Rights reserved.