Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have requirement to convert all http requests to https requests and append .xyz.com to the server name. For that i have written the following rule which is working for http requests but does not work for https requests.

RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R]

If I type http:// lvldraspnetserv01, it redirects to https:// lvldraspnetserv01.xyz.com as required.

However, if I type https:// lvldraspnetserv01 it does not redirect to https:// lvldraspnetserv01.xyz.com, causing the certificate to fail.

share|improve this question
    
You need a certificate for lvdraspnetserv01. In this case the certificate validation happens before the redirect. –  matthew Apr 7 '11 at 15:39

2 Answers 2

Try it like this:

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} **Insert current condition here ***
RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} **Insert current condition here, but for https***
RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R]
share|improve this answer
    
I did not understand what do you mean by "Insert current condition here **" and "*Insert current condition here, but for https*" –  user77491 Apr 7 '11 at 10:21
    
Post your complete config above :-). I'll have a look. –  Bart De Vos Apr 7 '11 at 16:48

I had the same problem.

Adding the QSA flag solved the problem

RewriteRule ^(.*)$ https://%{SERVER_NAME}\.xyz.com%{REQUEST_URI} [R, QSA]

Strange behavior isn't it ? :)^^

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.