.htaccess - Disable rewrite to https for subdomains -


i use rewrite https of calls of .htaccess file.

i want avoid http://foo.myhost.com gets rewritten https://www.myhost.com

it should stay

http://foo.myhost.com <-note, not https

<ifmodule mod_rewrite.c> rewriteengine on rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] </ifmodule> 

add negated condition avoid matching subdomain:

rewriteengine on  rewritecond %{http_host} !^www\. [nc,or] rewritecond %{https} off rewritecond %{http_host} !^(?!www\.)[^.]+\.myhost\.com$ [nc] rewriterule ^ https://www.myhost.com%{request_uri} [l,r=301] 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -