It all works great until I try to enter the site with the none www. prefix.
get rid of that RewriteCond - in your case hostname should be irrelevant at this point. before that internal rewrite to the magento directory, you want to do an external redirect to the root directory when the /magento/ path is requested. this redirect should include the fully qualified canonical protocol and hostname in the target. after this redirect and before the internal rewrite(s), you need another canonical hostname redirect to handle requests for other url paths. and maybe another one before that for index directory document requests.