Forum Discussion
Multiple domain redirection
Hi,
There is one requirement to redirect 2 Host domains -
lab.com -> https://lab.com/bluelab/login.html
uatlab.com -> https://uatlab.com/bluelab/login.html
We are using single Virtual Server & HTTP::host based irule for backend Pool connectivity.
Tried below irule for redirection - but redirection is not working for both host domains
when HTTP_REQUEST {
if {[HTTP::host] equals "lab.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://lab.com/bluelab/login.html"
if {[HTTP::host] equals "uatlab.com" and [HTTP::uri] equals "/"} {
HTTP::redirect "https://uatlab.com/bluelab/login.html"}
}
}
Once i tried below irule on VS redirection started working for lab.com
irule lab.com-redirection
when HTTP_REQUEST {
if { [HTTP::host] equals "lab.com"} {
if { [HTTP::path] equals "/" }
{
HTTP::redirect "https://lab.com/bluelab/login.html"
}
}
but once below irule is applied on same VS along with above irule both host domain rediection stopped working & even both site went down.
irule uatlab.com-redirection
when HTTP_REQUEST {
if { [HTTP::host] equals "uatlab.com"} {
if { [HTTP::path] equals "/" }
{
HTTP::redirect "https://uatlab.com/bluelab/login.html"
}
}
Please share the irule for multiple host redirection to be configured on a single irule & can be applied to a signle VS.
Hi Preet_pk,
You are probably getting a tcl error, you can see it in the ltm logs.
https://support.f5.com/csp/article/K23237429when HTTP_REQUEST { if {[HTTP::has_responded]} { return } if {[HTTP::host] equals "lab.com" and [HTTP::uri] equals "/"} { HTTP::redirect "https://lab.com/bluelab/login.html" return elseif {[HTTP::host] equals "uatlab.com" and [HTTP::uri] equals "/"} { HTTP::redirect "https://uatlab.com/bluelab/login.html"} return } }
shorter:
when HTTP_REQUEST { if { [HTTP::has_responded] } { return } if { [HTTP::uri] eq "/" and ([HTTP::host] eq "lab.com" or [HTTP::host] eq "uatlab.com") } { HTTP::redirect "https://[HTTP::host]/bluelab/login.html" return } }
- Ahmed_GalalCirrostratus
you can configure LTM policy condtion based on hostname and URI and action with redirection URL.
Recent Discussions
Related Content
* 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