Forum Discussion
url/uri to url/uri with potential header rewrite involved
Ok, I think I am really close but I am finally admitting I am confused. My clients want to be able to type the url http://bearcub.dev.leo.world.com/lookout and be redirected to http://lion.dev.leo.world.com/lookout Okay, this works , with the following url, when HTTP_REQUEST { if {[string tolower [HTTP::host]] equals "bearcub.dev.leo.world.com" and [string tolower [HTTP::uri]] equals "/lookout" } { HTTP::redirect "http://lion.dev.leo.world.com/lookout" } }
Now, my client want to be able to type the url http://bearcub.dev.leo.world.com/lookout and be redirected to http://lion.dev.leo.world.com/lookout but want the url browser to still display http://bearcub.dev.leo.world.com/lookout so in essence, the user will be directed to the page http://lion.dev.leo.world.com/lookout but the url will still show no change , it should still show http://bearcub.dev.leo.world.com/lookout this sounds like a header re-write type of scenario which is confusing the heck out of me.
5 Replies
- nathe
Cirrocumulus
Shlairshe,
I think this rewrite should work. Can't lab it at the moment to test.
when HTTP_REQUEST { if {[string tolower [HTTP::host]] equals "bearcub.dev.leo.world.com" and [string tolower [HTTP::uri]] equals "/lookout" } { HTTP::header replace Host "lion.dev.leo.world.com" } }Hope this works, sure other DCers will correct me if wrong.
N
- Kevin_Stewart
Employee
The HTTP::redirect command sends a 302 responses to the client that will surely change the URL in the browser. If you want this to be hidden then you would, at a minimum, just change the Host header:
when HTTP_REQUEST { if { ( [string tolower [HTTP::host]] equals "bearcub.dev.leo.world.com" ) and ( [string tolower [HTTP::uri]] equals "/lookout" ) } { HTTP::header replace Host "lion.dev.leo.world.com" } } - Kevin_Stewart
Employee
The point is this. If you issue a redirect, it's the client going to get the new host resource, so the browser host URL will have to change. If you don't want to change the browser URL, then you have to silently change the Host header on ingress (request) - without the browser's involvement.
- Kevin_Stewart
Employee
The last example I sent is what it might look like. The HTTP::header replace command will replace headers on ingress request flow without altering the client side URL.
- Shlairshe_84486
Nimbostratus
Guys, the following worked for what I was looking for. Created a pool with the server servicing the two sites, and took your advice on the header replace statement.
when HTTP_REQUEST { if { ([HTTP::uri] starts_with "/lookout") } { HTTP::header replace Host "lion.dev.leo.world.com" pool bearcub.dev.leo_pool }
Thanks for sticking with it, your input did truely lead me to this resolution.
Regards,
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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