Forum Discussion
IF http::host NOTEQUALS? Whats the correct way to do this?
I apologize but the formatting is not showing properly.
Im trying to find the "right way" to write this iRule - but I cannot confirm there is a "not equal" that exists....
when HTTP_REQUEST {
if { ([HTTP::host] notequals "orders.widgets.com") } {
HTTP::redirect "https://orders.widgets.com/redirectpage.html"
}
}
The reasoning for this is that we had a * (wildcard) cert and we are trying to get everyone off to use the main page. If they are not coming in on the main page as we have asked them - they will be redirected to a redirect warning page - hold there for 10 seconds and then the server (pool member) will redirect them to the appropriate page.
- Chris_Grant
Employee
This might help: https://devcentral.f5.com/articles/irules-101-02-if-and-expressions
Normally you'd use a ! to negate a match, so
when HTTP_REQUEST { if { ([HTTP::host] != "orders.widgets.com") } { HTTP::redirect "https://orders.widgets.com/redirectpage.html" } }
Don't forget to use string tolower before you try to match.
- Stanislas_Piro2
Cumulonimbus
Hi,
The right syntax is
To compare stringsne
when HTTP_REQUEST { if { ([HTTP::host] ne "orders.widgets.com") } { HTTP::redirect "https://orders.widgets.com/redirectpage.html" } }
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