Forum Discussion
Jeff_Morrison_4
Nimbostratus
Nov 01, 2007HTTP redirect and keep remaining uri path
I am trying to do a redirection from one external address to another based on certian part of the URL, but need the remaining address to be left in place after the redirection. For example:
https://www.domain.com/customer/asdd=??/12345/whatever
need to be redirectd to:
https://www.domain.com/DIFFERENT-CUSTOMER/asdd=??/whatever
Basically I only want the customer part changed.
I have tried the %u switch in my rule, but it fails. My current rule is:
when HTTP_REQUEST {
if { [HTTP::uri] contains "/customer1"
}{
pool WLS-Lab
} elseif { [HTTP::uri] contains "/xyzcustomer"}{
redirect to https://[HTTP::host]/customer1/
}}
This works but strips everything in the URL after xyzcustomer when it redirects to customer1.
Thanks for your help.
Jeff
4 Replies
- hoolio
Cirrostratus
You can use string map (Click here) to replace /customer/ with /DIFFERENT-CUSTOMER/.
I think it should work if you replace the current redirect with this:
redirect to https://[HTTP::host]/[string map {/customer/ /DIFFERENT-CUSTOMER/} [HTTP::uri]]
log local0. "redirecting to: https://[HTTP::host]/[string map {/customer/ /DIFFERENT-CUSTOMER/} [HTTP::uri]]"
Thanks,
Aaron - Jeff_Morrison_4
Nimbostratus
Thank you for the reply. It worked well..but my web developer doesn't want a Browers redirect as I first thought.
What he wants is the BIPIP to act as a proxy for the customer. So in my example the clients browser doesn't change, but the BIPIP will replace the xyxcustomer with customer1 for interanl purposes.
Seem like the replace would work..but haven't found the correct syntax.
Thanks Aaron for the help! Any ideas on this one?
Jeff - hoolio
Cirrostratus
You can also set the URI with HTTP::uri (Click here). The URI sent to the pool will be modified--as opposed to issuing a redirect to the client. Here's an example:when HTTP_REQUEST { if { [HTTP::uri] starts_with "/customer/"}{ pool WLS-Lab } elseif { [HTTP::uri] starts_with "/xyzcustomer"}{ HTTP::uri [string map {/xyzcustomer/ /customer/} [HTTP::uri]] } }
Aaron - Jeff_Morrison_4
Nimbostratus
Thanks Aaron....it worked really well
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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