Try removing the first slash. It won't match in a per-directory context because mod_rewrite automatically strips off the directory prefix for you.
Lots more info at:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule
Also, if you want "test.htm" to be redirected, you'll need to modify the regexp so dot characters are allowed.
code:
RewriteRule ^hosted/([^/]+)/?$ http://%{HTTP_HOST}/hosting.php?file=$1 [R]