lieutdan13
2012-01-27 16:08:49 UTC
My server hosts all requests to example.com, i.e. example.com, www.example.com,
customer1.example.com, customer2.example.com, etc. I have an SSL
certificate that is only valid for www.example.com, not even
example.com. I haven't been able to find a good answer to my question,
since it involves rewrites in different cases. Here's what I want to
do:
[code]
if HTTP_HOST == 'example.com'
// All requests for example.com, regardless of SSL, redirect to
SSL www site
redirect to https://www.example.com/theRestOfTheURL
else if HTTP_HOST == 'www.example.com' and SERVER_PORT != 443
// For non-SSL requests to www, redirect to SSL www
redirect to https://www.example.com/theRestOfTheURL
else if SERVER_PORT == 443
// For any other requests that are trying to use SSL, redirect to
non-SSL of the same domain name
redirect to http://HTTP_HOST/theRestOfTheURL
Carry out other RewriteRules I may have in place
[/code]
I would prefer to be able to accomplish this with .htaccess rules. But
if I need to accomplish this with a combination of .htaccess rules AND
Apache configuration changes, I'm ok with that too. Thank you in
advance!
customer1.example.com, customer2.example.com, etc. I have an SSL
certificate that is only valid for www.example.com, not even
example.com. I haven't been able to find a good answer to my question,
since it involves rewrites in different cases. Here's what I want to
do:
[code]
if HTTP_HOST == 'example.com'
// All requests for example.com, regardless of SSL, redirect to
SSL www site
redirect to https://www.example.com/theRestOfTheURL
else if HTTP_HOST == 'www.example.com' and SERVER_PORT != 443
// For non-SSL requests to www, redirect to SSL www
redirect to https://www.example.com/theRestOfTheURL
else if SERVER_PORT == 443
// For any other requests that are trying to use SSL, redirect to
non-SSL of the same domain name
redirect to http://HTTP_HOST/theRestOfTheURL
Carry out other RewriteRules I may have in place
[/code]
I would prefer to be able to accomplish this with .htaccess rules. But
if I need to accomplish this with a combination of .htaccess rules AND
Apache configuration changes, I'm ok with that too. Thank you in
advance!