Redirect not working in Apache, HTTP to HTTPS
<p>I want to redirect all of my HTTP requests to my HTTPS (SSL) protocol. Please guys this is not a duplicate. I have already tried every question found on SO which indicate such question but none of them worked. I tried everything I found on the internet but still cannot figure out what the problem is. May be somewhere something has to be enabled or something like that.</p>

<p>I want to redirect from my <code>httpd.conf</code> file not from <code>.htaccess</code> because this is what suggested by Apache Org. My current Redirection Rule is</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
&lt;/VirtualHost &gt;
</code></pre>

<p>I am making all of these changes in my <code>httpd.conf</code> file located in <code>/etc/httpd/conf/httpd.conf</code></p>

<p>After every change, I also restart my server with following <code>/etc/init.d/httpd restart</code> or <code>service httpd restart</code></p>

<p>I also tried following</p>

<pre><code>RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L]
</code></pre>

<p>But still when I visit my site like <code>www.example.com</code>, I am not redirected to <code>https://www.example.com</code>.</p>

<p>I have a VPS Server so has enough access to my machine to enable or disable something.</p>