Forum Discussion
cody8411_186897
Jan 29, 2016Nimbostratus
Handling www with host name redirects in iRule
I'm trying to figure out how I can handle the following situation. The section of the iRule below is for redirecting to a different URL based on a hostname. Our organization has purchased multipl...
Kai_Wilke
Jan 29, 2016MVP
Hi Cody,
you may try the performance optimized snippet below. It would require just a single data group query to check for existence and to retrieve the location value...
when HTTP_REQUEST {
if { [HTTP::host] starts_with "www." } then {
if { [set location [class match -value [string range [HTTP::host] 4 end] eq group_80_host_redirect]] ne "" } then {
HTTP::redirect $location
return
}
} else {
if { [set location [class match -value [HTTP::host] eq group_80_host_redirect]] ne "" } then {
HTTP::redirect $location
return
}
}
HTTP::redirect "https://www.company.com/unknown_hostname/error.html?host=[URI::encode [HTTP::host]]"
}
Cheers, Kai
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