www.example.com/folder/?p=5 being properly rewritten to www.example.com/index.php?page=main&p=5/
No, it isn't. It's being properly REDIRECTED.
If a redirect is really what you want, then include the full protocol-plus-domain in the target:
RewriteRule ^folder/(.*)$ http://www.example.com/index.php?page=main&$1 [QSA,R=301,L]
Otherwise everyone stays in whatever form of the domain name they originally requested: with or without www., with or without port number, possibly even IP address instead of domain name.
The RewriteBase directive is almost never needed, and definitely never
RewriteBase /
since that is the default anyway.
But do you really
want a redirect? It seems as if you are sending people to an uglier URL than the one they started out at, so you'd want a rewrite instead. That means no protocol-plus-domain, and no [R] flag.
You need to find out where and when the ending / is added so you don't come out with multiple redirects. If you can't stop the rule from executing before your Rewrite, change the .* to
([^/]*)/?
so the / isn't included in the capture. You'll need further tweaks if the request can ever involve a nested page like
directory/subdirectory/subsubdir/{et cetera}