Forum Discussion
d__383820
Nimbostratus
Feb 15, 2019URL Redirect Switch not detecting on host for base domain
I am wanting to redirect certain hosts to HTTPS for offload. my iRule is working for hosts within the domain (e.g. ) but not for base domain host (e.g. domain.com).
The below iRule is working fo...
Andy_McGrath
Cumulonimbus
Feb 16, 2019Expanding on from DannisJann’s answer, I recommend using
getfield
around the HTTP::host
command to remove any trailing port e.g. curl -iv http://domain.com:80/
should still match in the switch statement.
Also you do not need to use the
pool
command as you have not overwritten the Virtual Server configured pool earlier in the iRule.
If you have used the
pool
command in an earlier iRule then you may want to put your pool selection back in but recommend using pool [LB::server pool]
instead of the pool by name.
when HTTP_REQUEST {
switch [string tolower [getfield [HTTP::host] : 1]] {
"domain.com" -
"www.domain.com" -
"uat.domain.com" {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
}
default {
return
}
}
}
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