I have a domain having two subdomain, I want that if someone type www.example.com or http://example.com , he should redirect to https://example.com but in case of subdomain he shouldn't redirect, eg: if he type http://subdomain.example.com, he shouldn't go to https://subdomain.example.com. I am using below general htaccess code,
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%1%{REQUEST_URI}
But this code is redirecting all trafic to https including subomain. please help me to write htaccess code which will not redirect subdomain to https:// but other all trafic to https
I feel you should try the code below.
if above rules not worked than try to replace the above rule with this one