Forum Discussion
Jeremy_C_Russel
Nov 14, 2011Nimbostratus
Possible issue with an iRule
Greetings all.
I wanted to get some eyes on this particular rule I've setup. The premise is to take urls in the form of http://string.domain.com or http://www.string.domain.com, capture "st...
nitass
Nov 14, 2011Employee
Aaron,
nice irule. 🙂
by the way, should we also remove top-level domain?
e.g.
[root@ve1023:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
Remove www. from the host header value if it is present
scan [string map {www. ""} [string tolower [HTTP::host]]] {%[^.]} host
log local0. "[IP::client_addr]:[TCP::client_port]: Parsed $host from [HTTP::host]"
switch $host {
"domain" -
"wsecure" -
"ssl" {
do something
}
default {
log local0. "[IP::client_addr]:[TCP::client_port]: Matched part of $host, redirecting"
HTTP::redirect "https://www.domain.com/MS/RedirectMS?site=hub&value=$host"
}
}
}
}
[root@ve1023:Active] config curl -I http://www.abc.com/test
HTTP/1.0 302 Found
Location: https://www.domain.com/MS/RedirectMS?site=hub&value=abc
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve1023:Active] config
Nov 14 07:29:34 local/tmm info tmm[4766]: Rule myrule : 172.28.65.150:46973: Parsed abc from www.abc.com
Nov 14 07:29:34 local/tmm info tmm[4766]: Rule myrule : 172.28.65.150:46973: Matched part of abc, redirecting
[root@ve1023:Active] config curl -I http://abc.com/test
HTTP/1.0 302 Found
Location: https://www.domain.com/MS/RedirectMS?site=hub&value=abc
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve1023:Active] config
Nov 14 07:29:43 local/tmm info tmm[4766]: Rule myrule : 172.28.65.150:46974: Parsed abc from abc.com
Nov 14 07:29:43 local/tmm info tmm[4766]: Rule myrule : 172.28.65.150:46974: Matched part of abc, redirecting
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