Qasim
November 28, 2019, 12:35pm
1
Hi Could you please help me with this IRULE that I am trying to make it work:
I have created a data group list: private_net and basically if the client IP doesn’t match the http header, path and remote client IP then redirect to a home page:
when HTTP_REQUEST {
if { [HTTP::host] contains “syst3-my.test.co.uk ” and [HTTP::path] starts_with “/test/cs*” and not !([class match [IP::remote_addr] equals “private_net”]) } {
HTTP::redirect “https://syst3-my.testco.uk/test/home ”
}
}
I am not great with IRule so not sure what am I doing wrong.
will really appreciate your help as its pretty urgent.
thank you
Hi,
Can you try this?
when HTTP_REQUEST {
if { ([HTTP::host] contains "syst3-my.test.co.uk") and ([string tolower [HTTP::path]] starts_with "/test/cs") } {
if { not ([class match [IP::client_addr] equals private_net]) } {
HTTP::redirect "https://syst3-my.testco.uk/test/home"
}
}
}
Qasim
November 28, 2019, 1:38pm
3
HI Mate, thanks for your swift help really appreciate it.
wondering how do I match another URL path as well if I say host match syst3-my.test.co.uk and URL either starts with “/test/cs” or “/test12/cs”
thank you
when HTTP_REQUEST {
if { ([HTTP::host] contains "syst3-my.test.co.uk") and ([string tolower [HTTP::path]] starts_with "/test/cs" or [string tolower [HTTP::path]] starts_with "/test12/cs") } {
if { not ([class match [IP::client_addr] equals private_net]) } {
HTTP::redirect "https://syst3-my.testco.uk/test/home"
}
}
}
If you want redirect for more path, you can use “switch ” statement.
Qasim
November 28, 2019, 2:08pm
5
I have applied the Irule to the VS but for some reasons it wont work. this is a standard VS with a default pool assigned.
Qasim
November 28, 2019, 2:18pm
6
actually mate, its works like a charm. thank you very much!