Infinite Redirect Loop When Going From non-SSL to SSL


I’m trying to get things up and running in a cloud environment.

when I click on pages(ASP.NET) that use HTTPS protocol, page hangs. I think it is really doing the loop due to re-direction from HTTP to HTTPS.

Any ideas on how to fix this?

I tried asking tech support environment and they told me to use SSL throught my site or don’t use it.

Please help!!




=========== Answer 1 ===========

.IsSecureConnection doesn’t work. You have to use an environment variable to check for SSL

=========== Answer 2 ===========

correct! I had the following code:

if (!Request.IsSecureConnection)
// send user to SSL
string serverName =HttpUtility.UrlEncode(Request.ServerVariables[“SERVER_NAME”]);
string filePath = Request.FilePath;
Response.Redirect(“https://” + serverName + filePath);

and it hangs. what is the equivalent code that I should use for cluster environment? Thanks,


=========== Answer 3 ===========

if(Request.ServerVariables[“HTTP_CLUSTER_HTTPS”] != “on”) { // we need to redirect
// check to see if the other Server Var is defined, if not redirect otherwise dont

if(Request.ServerVariables.Get(“HTTP_CLUSTER-HTTPS”) == null) {
Response.Redirect(“https://” + Request.ServerVariables[“HTTP_HOST”] + newUrl);

Here is another one:


<rule name=”Redirect to HTTPS” stopProcessing=”true”>
<match url=”(.*)” />
<add input=”{HTTP_CLUSTER_HTTPS}” pattern=”^OFF$” />
<action type=”Redirect” url=”https://{HTTP_HOST}/{R:1}” redirectType=”SeeOther” />


=========== Answer 4 ===========

Yep, I linked too fast. I linked to a thread on getting the IP address for SSL, which is related, but different.

You may want to take note of it though, because you may at some point want to get the IP address of your visitors, and ServerVariables(“REMOTE_ADDR”) won’t work, you’ll need the HTTP_X_FORWARDED_FOR variable if you are on SSL.

=========== Answer 5 ===========


I am using URLRewriter an open source module. Following is the script I use

<if header=”HTTP_HOST” match=”^www.MyDomain\.com$”>
<redirect url=”^(.+)$” to=”$1″/>
<!–<if header=”HTTP_CLUSTER_HTTPS” match=”^OFF$”>
<redirect url=”^~/test.aspx$” to=””/>

I tested this last night and the page still hangs.



Rackspace Secrets

Leave a Reply

Your email address will not be published. Required fields are marked *