.htaccess mod_rewrite [P] for https

I have the following code in my .htaccess:

<ifModule mod_rewrite.c>
#RewriteCond %{HTTP_HOST} ^www.example.com
RewriteCond %{REQUEST_URI} !^/social/retrievePage.php 
RewriteRule ^(.*)$ http://www.example.com/social/retrievePage.php?page=%{REQUEST_URI} [P]
</ifModule>

Basically it will remap any page to https://www.example.com/social/retrievePage.php and pass REQUEST_URI as page GET parameter.

It works well, however when I set SSL certificate for my domain, this will not work as expected, instead of remapping it will make a 301 Redirect

I tried fixing the issue by replacing http to https from RewriteRule, got 500 Internal Server Error.

What could be the issue?


Source: stackoverflow-php