I wish to redirect one specific url like:

www.example.com/test/ex.gif

to

static.example.com/ex.gif

How do i do that inshtaccess?

From the top my mind:

RewriteRule ^http://www.example.com/test/ex.gif$ http://static.example.com/ex.gif [NC,R=301]

in order to any file in test:

RewriteRule ^http://www.example.com/test/(.*)$ http://static.example.com/$1 [NC,R=301]

Remedied after advice from Mr. Berardi

Do this mod_rewrite rule:

RewriteEngine on
RewriteRule ^test/(.*) http://static.example.com/$1

Or this mod_alias directive:

Redirect /test/ http://static.example.com/