apache - Apply SSL only to main domain - .htaccess -


we have purchased free ssl hostgator. when upgrade package.

now, have 1 main domain (www.example.com) , 2 sub-domains (www.sub.example.com) & (www.sub.example.com).

i've inputted code .htaccess:

rewriteengine on rewritecond %{server_port} 80 rewriterule ^(.*)$ https://www.example.com/$1 [r=301,l] 

main domain works fine, when want go sub-domain, redirected main domain => www.example.com .

i understand it's because of ^(.*)$ part, best solution this?

i want ssl main domain , http subdomains.

add condition exclude subdomain https redirection

rewriteengine on rewritecond %{http_host} !^(www\.)?sub\.domain\.com rewritecond %{server_port} 80 rewriterule ^(.*)$ https://www.example.com/$1 [r=301,l] 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -