Forum Discussion
JamesLapic_4428
Nimbostratus
Aug 21, 2007Redirect based on Host Header and Hide URI?
I have a pool of web servers that i am trying to accomplish the following on.
- Any traffic directed to app1.example.com would be redirected to app1.example.com/dir1/dir2/index?id=1&lang=0
- Any traffic directed to app2.example.com would be redirected to app2.example.com/dir1/index?id=1
It would be nice if the client never saw the redirection and only http://app1.example.com in the address bar. Is this possible?
I have been trying different irules using HTTP::redirect, but have yet to get a good solution in place.
Thanks,
-james
- Chad_Roberts_21
Nimbostratus
HTTP::redirect actually sends a redirect to the client's browser, so with that method you won't be able to get around the user seeing it. You could try simply modifying the URL (specifically, the uri) before forwarding it to the pool, though. It would appear to the user that the path is just "/", which of course is the root directory (default when no path is specified).when HTTP_REQUEST { if { ([HTTP::host] == "app1.example.com") and ([HTTP::uri] == "/") } { HTTP::uri "/dir1/dir2/index?id=1?=0" } if { ([HTTP::host] == "app2.example.com") and ([HTTP::uri] == "/") } { HTTP::uri "/dir1/index?id=1" } }
- Kirk_Bauer_1018
Nimbostratus
You could probably hack up my ProxyPass iRule (posted here) to do just the initial redirect pretty easily, but then you get into issues of relative URLs, etc. Let's assume a client hits http://app2.example.com/ and we don't send a redirect but internally map them to app2.example.com/dir1/index?id=1. Now imagine if there was "logo.jpg" on the app2.example.com/dir1/index?id=1 page. The client would request http://app2.example.com/logo.jpg, but how should that be translated, if any, on the way through? Should it be http://app2.example.com/dir1/logo.jpg?id=1 maybe? Or just http://app2.example.com/dir1/logo.jpg?
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