irule variable

Hi, I need to create an irule that looks for the first part of a URI in a web request and then appends that value as a folder. For instance: test.host1.example.com would need to be processed and then redirected to host1.example.com/a/b/test/z1/

does anyone know what is the best way to program this as an irule?

thanks!!

Ed

are a, b and z1 directories static or it can be anything?