Redirect iRule

Hi all,

I am trying to set an iRule to redirect HTTP request to a different URL. Basically for testing purpose, I created a WideIP which resolves to a WebServer which displays a Blue Page. I added a CNAME in DNS calling it Test Blue so what I want is to redirect anything that has testblue in the URL to redirect to an internal webpage called

This is the iRule I am using but I am getting errors

when HTTP_REQUEST { if { (([HTTP::host] contains “testblue”)) } { HTTP::redirect "; } }

The error is

01070151:3: Rule [/Common/testblue_irule] error: /Common/testblue_irule:1: error: [unknown event (HTTP_REQUEST)][when HTTP_REQUEST { if { (([HTTP::host] contains “testblue”)) } { HTTP::redirect "; } }]

Can someone point where I am going wrong with this.

Many Thanks

Try below iRule.

when HTTP_REQUEST { 
  if { [HTTP::host] contains "testblue" }
  { HTTP::redirect "https://open/open" } 
     }

Hi there,

This didnt work unfortunately

Need a wee bit more info…

Where are you editing the rule? In the iRule editor? or in the GUI itself? The error comes back how? In the logs? Or in the mechanism you’re using to add it?

At a guess, it looks like you’ve added an iRule as an HTTP_REQUEST event that has as it’s first line ‘event HTTP_REQUEST’… (Sorry, not got access today to my test box to verify that myself)

Try switch statement to match wildcard.

when HTTP_REQUEST {
switch -glob -- [HTTP::host] {
  "*testblue*" { HTTP::redirect "https://open/open" }
 default { reject }
  }
 }

I have the same error, look more like a bug than issue with the iRule itself

Executive same irule on other F5 device to check if any device specific issue.

Tried on the Virtual F5 with a Lab licence running 11.6.1 Same issue

I tested this on LTM and the iRule saved without any issue. But GTM/DNS still gives issues.

Ok as per F5 support, HTTP_Request will not work on DNS/GTM and thats where I was getting unknown event.

Testblue is hosted on the F5 is hosted on the NetScaler (Blasphemy!! I know)

With that in mind can we have an irule so that when we have a DNS request of testblue, the Big-IP forwards the traffic to

You’re using a GTM iRule? That’s at DNS level so HTTP_REQUEST is not a valid event…

FWIW there’s very few times you’d need a GTM iRule. And never when trying to operate at the HTTP level.

Sorry, when you posted this one I assumed you’d put the iRule on the LTM (at the VS) to do the redirect…