Forum Discussion

Bob_66655's avatar
Bob_66655
Icon for Nimbostratus rankNimbostratus
Oct 10, 2018

F5 host header rewrite different domain

Im trying to do rewrite of https://abc.com/code/* to https://xyz.com/*

 

when HTTP_REQUEST {

 

         if { [HTTP::host] contains "abc.com" && [HTTP::uri] starts_with "/code" }                
           {
           HTTP::header replace Host "xyz.com" 
           HTTP::uri [string map {"/code" ""} [HTTP::uri]] 
           }
         }
    }

But it seems to be failing with bad request,am I trimming too much of uri?

 

Bob

 

1 Reply

  • Your iRule looks fine and the string map logic is correct - I've tested it nativity in TCL:

    % set uri /one/two/three
    /one/two/three
    % set new [string map {"/one" ""} $uri]
    /two/three
    

    If you are receiving a bad request from the pool member - it maybe that the new URI is incorrect and the web server is unable to process it.