Forum Discussion
MatthewStyles_3
Nimbostratus
Jun 26, 2018iRule to redirect URL based on source address
Hi there,
I am looking to see if it is possible to have an iRule build in the following functionality to a website:
Allow internet access to https://mywebsite.co.uk for all internet traffic...
Lee_Sutcliffe
Nacreous
Jun 26, 2018You could use a simple iRule like this
when HTTP_REQUEST {
if {([HTTP::uri] equals "/admin") || ([HTTP::uri] equals "/admin2")} {
if {!([IP::client_addr] equals "10.0.0.1")} {
HTTP::redirect https://mywebsite.co.uk
}
}
}
You could also use a datagroup to store your IP addresses if you plan on using more than one:
when HTTP_REQUEST {
if {([HTTP::uri] equals "/admin") || ([HTTP::uri] equals "/admin2")} {
if {!([class match [IP::client_addr] equals "my_datagroup"])} {
HTTP::redirect https://mywebsite.co.uk
}
}
}
You can take this a step further and add the URIs to a datagroup too:
when HTTP_REQUEST {
if {[class match [HTTP::uri] equals "my_uri_datagroup"]} {
if {!([class match [IP::client_addr] equals "my_ip_datagroup"])} {
HTTP::redirect https://mywebsite.co.uk
}
}
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects