Proper Rules For SSL Redirect For Subdomains

Posted by Zac Cleaves on Super User See other posts from Super User or by Zac Cleaves
Published on 2012-12-13T22:36:00Z Indexed on 2012/12/14 17:06 UTC
Read the original article Hit count: 177

Filed under:
|
|
RewriteCond %{HTTP_HOST} ^(.*\.)*subexample.example.com$ [NC]
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)$ https://subexample.example.com/$1 [R]   

Is what I have been using. It works as long as I go to a specific page, like subexample.example.com/orders.php. But if you try to go to the root of the subdomain, it adds the extra "/example" at the end.

Any suggestion on a set of rules that will work?


Thank you so much for your responces!

Actually, this is what I am trying to do:

http://support.mydomain.net >> https://support.mydomain.net

AND(!)

http://support.mydomain.net/anypage* >> https://support.mydomain.net/anypage*

> RewriteCond %{HTTPS} off RewriteRule (.*)
> https://%{HTTP_HOST}%{REQUEST_URI}

Works, except I need it to only do it for the support.mydomain.net

With the above set up, you get a certificate warning if you try to go just mydomain.net, which I do not have or need an SSL certificate installed on.

UPDATE!

The other issue with the rule I have written above, is that if you try to go to the root of the subdomain (i.e. support.mydomain.net) it goes to https://support.mydomain.net/support

This is driving me crazy, help! =)

Any help would be greatly appreciated!

© Super User or respective owner

Related posts about redirection

Related posts about ssl