Ok I've been reading a lot of the threads on this topic and it seems most have servers which work like this:

if test.mydomain.com is not a real subdomain it will go to mydomain.com

but on my server if test.mydomain.com doesnt exist, it gets a 'cannot find server' message.

I have no access to httpd.conf, so I am looking for a .htaccess solution to do this:
test.mydomain.com/anyfile.html should go to www.mydomain.com/anyfile.html
but the URL should stay as test.mydomain.com/anyfile.html
I tried using redirects, but it redirects them as 301's because I redirect to http://www.mydomain.com

If i try putting a RewriteCondition in the root dir to catch the sub-domain requests it does not work. Any solutions?