Forum Discussion

dkinsler_23191's avatar
Icon for Nimbostratus rankNimbostratus
Oct 13, 2010

Redirect 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 and This Irule would be placed on to redirect the contect to if the URI starts with /stuff.



when HTTP_REQUEST { if { [HTTP::uri] starts_with "/stuff"} { HTTP::redirect "[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

  • 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 }}
  • 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 Or is it the same as



  • 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?


  • 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


  • 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".