Forum Discussion
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
- Samir_Jha_52506
Noctilucent
Try below iRule.
when HTTP_REQUEST { if { [HTTP::host] contains "testblue" } { HTTP::redirect "https://open/open" } }
Hi there,
This didnt work unfortunately
- Samir_Jha_52506
Noctilucent
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
- Hamish
Cirrocumulus
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)
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
- Hamish
Cirrocumulus
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...
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com