subdomain irule redirect

Hi all,

I’m trying to get an iRule to do this:

http://*anything*.domain.com/blah/blah redirect to http://www.domain.com/blah/blah

Any help would be much appreciated.

Use getfield:

when HTTP_REQUEST { 
   if { [HTTP::host] contains "domain.com"} { 
     HTTP::redirect http://www[getfield [HTTP::host] ".domain.com" 2][HTTP::uri] 
   } 
 }

Click here for the wiki page for getfield.

Thanks a bunch.