Forum Discussion
Basil_Parsley_1
Aug 22, 2016Nimbostratus
Irule - HTTP redirect with a rewrite.
Guys,
I have a HTTP(S) redirect requirement ; I am migrating Apache load balancer webservices to F5.
The requirement is to redirect
https://webname.com/aaa/Default.aspx?ID:CUST=123 ...
- Aug 22, 2016
Append
to your redirect destination (sample below). The only problem with this approach is that you will always be redirected to a location with ?-symbol at the end, whether you have any query parameters in the original request or not.?[HTTP::query]
HTTP::respond 302 Location "https://webname.com/bbb/default.aspx?[HTTP::query]"
If the above bothers you, you can write a condition to determine if the question mark should be appended or not as follows
Determine if original request contains query parameters if { [HTTP::query] ne "" }{ set myQuery "?[HTTP::query]" } else { set myQuery "" } your condition goes here HTTP::respond 302 Location "https://webname.com/bbb/default.aspx$myQuery"
Hannes_Rapp_162
Nacreous
Append
?[HTTP::query]
to your redirect destination (sample below). The only problem with this approach is that you will always be redirected to a location with ?-symbol at the end, whether you have any query parameters in the original request or not.
HTTP::respond 302 Location "https://webname.com/bbb/default.aspx?[HTTP::query]"
If the above bothers you, you can write a condition to determine if the question mark should be appended or not as follows
Determine if original request contains query parameters
if { [HTTP::query] ne "" }{
set myQuery "?[HTTP::query]"
} else {
set myQuery ""
}
your condition goes here
HTTP::respond 302 Location "https://webname.com/bbb/default.aspx$myQuery"
Basil_Parsley_1
Sep 08, 2016Nimbostratus
Thanks - the more simplex answer met my requirements, and worked ; appreciated the detail.
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