[SOLVED] SSL redirect not working

Hi I am using this code in my Rewrite Rules for redirecting to www SSL but my site not redirecting to www SSL

RewriteCond %{HTTPS} !on
RewriteRule ^/(.*)$ https://www.example.com/$1 [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

OK Fixed my issue, I used rewrite template and now working perfectly.