How do I force HTTPS (Cloudflare Flexible SSL)?
<p>I am using Cloudflare Flexible SSL on a website I programmed myself (no framework or CMS). Everything is working and now I want to use HTTPS on the whole site. I use PHP on Apache web server.</p>

<p>I am wondering how I should approach this and redirect all users to HTTPS.</p>

<p>Currently my .htaccess is set up like this:</p>

<pre><code># Force www.
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
</code></pre>

<p>I have seen <a href="https://stackoverflow.com/questions/4083221/how-to-redirect-all-http-requests-to-https?lq=1">this answer</a> on stackoverflow, but it points to <a href="https://stackoverflow.com/a/21798882/56974">another answer</a> which is not as simple and <a href="http://httpd.apache.org/docs/current/rewrite/avoid.html#redirect" rel="nofollow noreferrer">doesn't recommend rewrites</a>.</p>

<p>This is the Apache recommendation:</p>

<pre><code>&lt;VirtualHost *:80&gt;
    ServerName www.example.com
    Redirect "/" "https://www.example.com/"
&lt;/VirtualHost &gt;

&lt;VirtualHost *:443&gt;
    ServerName www.example.com
    # ... SSL configuration goes here
&lt;/VirtualHost &gt;
</code></pre>

<p>But frankly, I have no clue what this means.</p>

<p>How can I redirect users to HTTPS and www? Anything I should be aware of, when switching to HTTPS?</p>