Forum Discussion
Redirection based non URI using iRule for an HTTPS Virtual Server
we have virtual server configured on 443 and offloading SSL as well. Please help me with the iRule to redirect URL based on URI key words.
For example, if the URL is https://abc.com, it should redirect to https://abc.com/client/servcie/
Tried the below iRules and none of them are working:
iRule1:
when HTTP_REQUEST { if {[HTTP::host] equals “abc.com” } { HTTP::redirect "https://abc.com/client/servcie/"; } }
iRule2:*
when HTTP_REQUEST { if {[HTTP::uri] contains"abc"} { HTTP::redirect "https://abc.com/client/servcie/";} }
iRule3:*
when HTTP_REQUEST { if { [HTTP::uri] equals "abc.com"}{ log local0. "PATH MATCH / URI: [HTTP::uri] HOST: [HTTP::host]" HTTP::redirect "https://abc.com/client/servcie/"; } }
iRule4-But its looping:
when HTTP_REQUEST { if { [HTTP::host] equals "abc.com" } { HTTP::respond 301 "Location" "https://abc.com/client/servcie/[HTTP::uri]" } }
it is a pretty common request so you can also first do some searching there will be many similar posts with working answers.
just looking at them from a syntax / logic point of view.
; isn't needed in tcl / irules, try without it
looking for just a host header and then redirecting to the same host header but with a different uri will cause a loop by default. as the redirect will hit the same irule which again see that host header so redirects.
so your initial host header check should probably include a uri check also, so if host header is abc.com and uri is empty or /
good luck.
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