Forum Discussion
John_Heyer_1508
Cirrostratus
Jul 13, 2015How to get domain name in iRule?
I have a redirect rule that I need to apply to about 30 different FQDNs:
foo.domain1.com/XYZ -> bar.domain1.com/XYZ
foo.domain2.com/XYZ -> bar.domain2.com/XYZ
foo.domain3.com/XYZ -> bar.domain3....
cjunior
Nacreous
Jul 13, 2015Hi,
If you do not need to treat the domain name, you could do this with the "string map" statement.when HTTP_REQUEST {
if { [HTTP::host] starts_with "foo." } {
HTTP::redirect "https://[string map -nocase {foo. bar.} [HTTP::host]][HTTP::uri]"
}
}
otherwise, you could treat it with "string range" and "string first" statement.
when HTTP_REQUEST {
if { [HTTP::host] starts_with "foo." } {
set dotdomain [string range [HTTP::host] [string first . [HTTP::host]] end]
set host bar$dotdomain
set url https://$host[HTTP::uri]
log local0. "Domain $dotdomain | Host: $host | Url: $url"
HTTP::redirect $url
}
}
It's just a tip, I hope it helps you. Regards
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
