Forum Discussion
Jules_M__Green
Nimbostratus
Oct 28, 2019Multiple errors with redirect iRule referencing data groups that was previously working
I am having a strange problem with an iRule that was working fine, and a few days later it is giving me multiple errors and I cannot pinpoint why. I want to note that the redirect looks to be working...
Oct 28, 2019
Hi Jules,
Can you try this?
I added else statement for "if { [HTTP::uri] == "/" }"
when HTTP_REQUEST {
# log local0. "Host: [HTTP::host] and URI: [HTTP::uri]"
if { [HTTP::uri] == "/" } {
# searches for a hostname match in datagroup and redirects to the hostname match value <the redirect path> if found
if { [class match [HTTP::host] equals chevron--internal--redirect] } {
HTTP::respond 302 Location "[class match -value [HTTP::host] equals chevron--internal--redirect]"
}
else {
# No match found log and redirect to error page
log local0.info "Redirect for '[HTTP::host][HTTP::uri]' was not found in data group 'chevron--internal--redirect'"
HTTP::redirect http://www.404errorpages.com
}
}
else {
# searches for a hostname+uri match in datagroup and redirects to the hostname+uri match value <the redirect path> if found
if { [class match [HTTP::host][HTTP::uri] equals chevron--internal--redirect] } {
# log local0. "matched host and uri"
HTTP::respond 302 Location "[class match -value [HTTP::host][HTTP::uri] equals chevron--internal--redirect]"
}
elseif { [class match [HTTP::host] equals chevron--internal--keepURI_redirect] } {
# searches for a hostname match in datagroup and redirects to the hostname match value <the redirect path> while keeping the uri if found
# example: mysite.com/help redirects to yoursite.com/help
# log local0.info "Redirect for '[HTTP::host][HTTP::uri]' was found in data group 'chevron--internal--keepURI_redirect'"
set myuri [HTTP::uri]
set myhost [class match -value [HTTP::host] equals chevron--internal--keepURI_redirect]
HTTP::respond 302 Location "$myhost$myuri"
}
else {
log local0.info "Redirect for '[HTTP::host][HTTP::path]' was not found in data group 'chevron--internal--redirect' or 'chevron--internal--keepURI_redirect'"
HTTP::redirect http://www.404errorpages.com
}
}
}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
