0

I have installed ssl on my site and my ssl license only work on base domain (not on sub domains)

i use following code in .htaccess file to redirect all http call to https. But the problem is it also redirect subdomain to my base doamin. for example www.sub.mydomain.com redirecs to https://www.mydomain.com :(

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mydomain.com/$1 [R=301,L]

but what i want, redirect only base domain call to https not interfere sub domains :(

1 Answers1

1
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} www.mydomain.com
RewriteRule (.*)  https://www.mydomain.com/$1 [R=301,L]

I think the rule could be just

RewriteRule (.*)  https://www.mydomain.com$1 [R=301,L]

leaving out the extra slash, which should be included in the rule match. But I always forget whether that works or not.

Andrew Schulman
  • 3,395
  • 1
  • 21
  • 23
  • opp! i faced a new problem, some of my previous script still use http, and i have no access to them and now they are not working.. can you help me a bit more, in the above rule so, i can exclude few php script file? for example: RewriteCond !{Old_Script.php} // it means if the url has "old_script.php" text/string in it then it will not redirect.. :) thanks in advance.. best regards –  Jan 08 '14 at 16:15
  • yes but my condition is not correct as i just write to help you to understand, can you give me exact condition to excluding any specific file (and directory) too.? –  Jan 09 '14 at 04:13