I have got a little trouble with mod_rewrite. This really is my code:

RewriteEngine on 
RewriteRule ^(.*)$ http://newsite.com/moved.php?q=$1 [R=301,L]

This almost works, basically visit oldsite.com/apage.php, I recieve rerouted to newsite.com/moved.php?q=apage.php.
However, basically visit oldsite.com/apage.php?var=15, I recieve rerouted to newsite.com/moved.php?q=apage.php again.
How could I make oldsite.com/apage.php?var=15 redirect to newsite.com/moved.php?q=apage.php?var=15 Thanks!

Make use of the QSA flag to obtain the original asked for query instantly appended towards the brand new one:

RewriteRule ^(.*)$ http://newsite.com/moved.php?q=$1 [R=301,L,QSA]