Explanation:RewriteEngine on this line turns rewrite engine on. otherwise it might fail.
RewriteBase /
this line sets rewrite base. this directive uses when wish to set base URL for per-directory rewrites. default value is current physical path but generally, URL-base in In a roundabout way associated with physical filename pathways, therefore it is wrong to make use of default. for instance when utilizing virtual directory you need to set this method properly to mod_rewrite act well.

RewriteCond %% ^(www.)?example.com/site/(.*)
within this line first apache joins to variable (host address: www.example.com and ask for URI : /site/var ). it inspections result with pattern I gave. to begin result can be www.
.after that needs to be example.com/site/ and also at the finish it may be anything.

RewriteRule (.*) http://site.example.com/%1 [R=301,L]

this line redirects user request to http://site.example.com/%1 with 301 status code. since it has L flag it is the last rewrite rule apache inspections.%1 is everything marked by (.*) in rewrite condition.

RewriteRule ^([^/\.]+)$ /site/?var=$1 [L]

this lines are the road you devote your question: it rewrites every URL that does not have / and us dot with /site/?var=$1.