Your 500 server error is likely reporting an 'infinite rewrite loop' -- Check your
server error log file. If you don't know where it is, ask your host. If there is no error log, plan get a new host if you are planning to do a lot of work with scripts and mod_rewrite.
Unless I'm missing something, you only need two rules, since "AnythingHere" includes "BlankHere," so one rule that accepts "anything" or "nothing" (as opposed to requiring "something") will cover both cases.
The key here is that in .htaccess, unless you explicitly state otherwise, any rule's output will be rewritten
again if it matches that (or any other rule's) pattern. Using the [L] flag --although it improves efficiency-- will not help this problem, because mod_rewrite in .htaccess behaves recursively.
So the following two rules should do what you described.
# Rewrite blog.domain.com/<AnythingHere> to /blog/<AnythingHere> if not already rewritten
RewriteCond %{HTTP_HOST} ^(www\.)?blog\.domain\.com$
RewriteCond $1 !^blog/
RewriteRule ^(.*)$ /blog/$1 [L]
#
# Rewrite anything-but-blog.domain.com to /folder_1/index.php?uid=anything
RewriteCond %{HTTP_HOST} ^(www\.)?([^.]+)\.domain\.com$
RewriteCond %2 !^blog$
RewriteRule ^(.*)$ folder_1/index.php?uid=%2 [L]
Note that it is incorrect to say "Rewrite anything.domain.com to
www.domain.com/folder_1/index.php?uid=anything", because you are rewriting "inside the server" so there is no "domain" in a rewrite, only a filepath. Therefore, I changed that description to "Rewrite anything.domain.com to /folder_1/index.php?uid=anything" in the comments in the code above.
Because of the form of the second rule, I will assume you are checking the client-requested URL-path within your script(s), because you wouldn't be able to have more that a single page Web site with no images or anything else unless this were true.
There's another problem, though, and that is that you are accepting both www- and non-www versions of your hostnames. You should 'pick one' and 301-redirect all www- requests to non-www (or vice versa) -- Either with an additional RewriteRule preceding the two posted here, or from within your script(s).
Jim