Forum Discussion
dkinsler_23191
Nimbostratus
Oct 13, 2010Redirect without rewriting host portion of URL
Hello all, I have a question about Redirecting. I have two VIPs and each has its own URL. I want one to redirect to the other under certain cconditions but I dont want the URL to change hosts. For instance....
I have mydomain1.com and mydomain2.com This Irule would be placed on mydomain1.com to redirect the contect to mydomain2.com if the URI starts with /stuff.
when HTTP_REQUEST { if { [HTTP::uri] starts_with "/stuff"} { HTTP::redirect "http://mydomain2.com/[HTTP::uri]" } }
The problem is, I dont want the users browser to see the domain change, but I want to get the contect from mydomain2.
Anybody have any ideas on how that should be done? Both vips are internal to the LB.
7 Replies
- Chris_Miller
Altostratus
I'm assuming you have different pools for each VIP?
Would it be acceptable to simply use the other pool?
Using your code:when HTTP_REQUEST { {if { [HTTP::uri] starts_with "/stuff" } { pool pool_mydomain2 } { else pool pool_mydomain1 }} - hoolio
Cirrostratus
If you want to hide the change in hostname from the client you would want to rewrite the Host header value and potentially select a different pool to send the requests to. You wouldn't want to send a redirect back to the client as this will update the address bar and the client will see the change. Is there a separate pool that serves content for mydomain2.com? Or is it the same as mydomain1.com?
Aaron - hoolio
Cirrostratus
Sorry Chris, I didn't see your reply.
Aaron - dkinsler_23191
Nimbostratus
It is a different pool associated with the mydomain2.com vip. - Chris_Miller
Altostratus
No worries Aaron.
This type of rule would also require OneConnect, right? If we're evaluating every HTTP request and sending certain ones to different pools? - Ben_95489
Nimbostratus
That's a great point, Chris.
While it may work (for the most part) without OneConnect, it's certainly a much better idea to enable it now instead of waiting for something to break later. Even if individual clients are only going to make requests for a single domain per connection, there are still lots of things that will reuse connections for more than one request - especially CDNs. They will often even reuse the same connection for requests from a myriad of different users.
// Ben - hoolio
Cirrostratus
If it's a different pool for each host name, you'd want to use an iRule like Chris suggested. You'd probably also want to rewrite the Host header if the different pool members expect a specific hostname. You can do this with "HTTP::header replace Host newhost.example.com".
Aaron
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
