Forcing HTTP traffic to HTTPS using .htaccess
<p>This is something for me I can never get right. I have tried lots of different methods but none of them seem to be working for me.</p>

<p>I want to force all traffic trying to access HTTP to be automatically redirected to HTTPS.</p>

<p>My .htaccess looks like this:</p>

<pre><code>RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www.)yourdomainname.com
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</code></pre>

<p>Not sure if it's relevant but my website is running on a VPS using Apache. </p>

<p>If someone could help me with a solution and what I was doing wrong it would be greatly appreciated. </p>

<p>EDIT: Here is my httpd.conf file: <a href="http://pastebin.com/VMYXGi0X" rel="nofollow">http://pastebin.com/VMYXGi0X</a></p>