[eluser]mddd[/eluser]
I think you could just check in routine #2 if the requested uriis not already /site/...
That way, the loop is broken. If someone goes to bar.foo.com, the redirection goes to /site/bar and at that time it will no longer match the condition so it will not redirect again.
Code:
RewriteCond %{HTTP_HOST} !^(www\.foo.*)$ [NC]
RewriteCond %{REQUEST_URI} !^site/ [NC]
RewriteCond %{HTTP_HOST} ^([a-z\-\_]*)\.foo\.([a-z\.]{2,5})$ [NC]
RewriteRule ^(.*)$ index.php/site/%1