title: https redirect for Network Solutions
body: <p>I am using Network Solutions as a hosting provider with a UNIX hosting package. I need to redirect certain pages to https (login, etc). After going through a lot of testing, I ended up with the following .htaccess entry:</p>
  
  <pre><code>RewriteEngine on
  
  RewriteCond %{SERVER_PORT} !^443$ [OR]
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*)$ https://[domain_redacted]/$1 [R=301,L]
  </code></pre>
  
  <p>This resulted in an infinite redirect loop. After discussions with Network Solutions, they told me I needed to 301 redirect (apparently what I was doing is not a 301 redirect ...), so I then tried the following in .htaccess:</p>
  
  <pre><code>Redirect 301 / https://[domain_redacted]/
  </code></pre>
  
  <p>This, of course, resulted in an infinite loop, as one would expect. Since none of these methods worked, I put the following php script on my server to test https detection through PHP:</p>
  
  <pre><code>&lt;?php 
  if(isset($_SERVER['HTTPS']) &amp;&amp; $_SERVER['HTTPS'] != 'off') { 
      echo 'HTTPS IS ON';
  } else {
      echo 'HTTPS IS OFF';
  } 
  ?&gt;
  </code></pre>
  
  <p>When requesting this page over both HTTP and HTTPS, the script returns OFF. </p>
  
  <p>So, what other methods exist to detect HTTPS server side in Apache or PHP?</p>