title: Redirecting from HTTPS to HTTP
body: <p>The webapp is built using CodeIgniter and the I'm using Cloudflare's Flexible SSL.</p>
  
  <p>The pages load over HTTPS, but whenever there is a redirect, the page loads over HTTP. From then on, all pages are served over HTTP.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>public function logout()
  {
      $this-&gt;session-&gt;sess_destroy();
      redirect('/');
  
  }
  </code></pre>
  
  <p>After the logout function, all pages are loaded over HTTP.</p>
  
  <p>How can I ensure that pages load over HTTPS after redirects?</p>
  
  <p>Here are the contents of my .htaccess file:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
  RewriteEngine On
  RewriteBase /
  
  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]
  
  RewriteCond %{REQUEST_URI} ^application.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]
  
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
  &lt;/IfModule&gt;
   &lt;IfModule !mod_rewrite.c&gt;
      ErrorDocument 404 /index.php
  &lt;/IfModule&gt; 
  
  RewriteEngine On 
  RewriteCond %{SERVER_PORT} 80 
  RewriteRule ^(.*)$ https://www.myurl.com/$1 [R,L]
  </code></pre>