The RewriteCond line checks to see if the domain is NOT
www.example.com or example.com... If it matches that rule, then it blocks access to it.
I'm kinda rusty in mod_rewrite, but there's a couple of things you could try.
RewriteRule ^ /404.php [NC] #This will redirect to 404.php which is the script below to just return a 404 error.
or
RewriteRule ^(.*)$ http://%1.example.com [R=301,L] #I believe this will do a 301 redirect from example.com/subdir to subdir.example.com
You may also need to take the '!' out of the rewritecond statement. I think it might be matching the reverse of what you want to match.
404.php:
<?php
header("HTTP/1.0 404 Not Found");
exit;
?>