I've got a website like www.example.com, I wish to redirect each hit for this URL and Sub Hyperlink to just one URL on subdomain. Following are a handful of good examples

www.example.com ought to be rerouted to http://test.example.com

www.example.com/show/mypage1 ought to be rerouted to http://test.example.com

www.example.com/show/mypage2 ought to be rerouted to http://test.example.com

www.example.com/show/mypage3 ought to be rerouted to http://test.example.com

I wish to get it done using .htaccess. and that i want 302 temporary redirect. I'm using Apache WebServer.

Are you currently using Apache or IIS?

In Apache:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://test.example.com/ [L,R=302]

edited

edited: changed http://test.example.com/$1 to http://test.example.com/, it really works now as needed.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
    RewriteRule ^(.*)$ http://test.example.com/ [L,R=302]
</IfModule>