1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SSL Detection

Discussion in 'Clustered Hosting Platform and Windows Hosting' started by Darren, Jan 20, 2010.

  1. Darren Administrator

    On our clustered hosting system, the method for SSL detection is a little different to what you might be familiar with. To facilitate SSL functionality across multiple web servers in a clustered environment we deploy a separate SSL load balancer. This means that sites can have SSL enabled with no downtime due to the IP change.

    If you are developing an application to run on your clustered hosting account, you may wish to detect whether or not the user is accessing your site over SSL and to redirect them appropriately.

    For PHP you should use the variable $_SERVER['HTTP_X_FORWARDED_PROTO'] which will be set to 'HTTPS' when the user is accessing over SSL (https://yoursite/) and will be unset when the user is not.

    Under ASP .NET (C#) you are looking for HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_PROTO"] which will be set to 'HTTPS' if the user is accessing over SSL and will be null if the user is not.

    Under classic ASP it's Request.ServerVariables("HTTP_X_FORWARDED_PROTO").

    If you need any assistance don't hesitate to contact support.
  2. Adam_Smith Member

    If you wanted to force SSL with a .htaccess rewrite, the rule would look like this:

    RewriteEngine On
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]

Share This Page