Forum Discussion

kevin_hendricks's avatar
kevin_hendricks
Icon for Nimbostratus rankNimbostratus
Feb 06, 2009

rewrite address bar in browser

Hi All,

 

I'm new to the world of irules and am trying to find something that will change the url in the address bar on the endusers browser.

 

so,, when they go to "aaa.myzone.com" I want them to see "bbb.mynewzone.com" in the address bar when the page displays.

8 Replies

  • Don_MacVittie_1's avatar
    Don_MacVittie_1
    Historic F5 Account
    Conveniently, that works out for you...

     

    I don't follow the iRules forum as closely, so this gets a response.

     

     

    Check out the iRule Redirector in the Labs section, it will do this pretty easily.

     

     

    Don.
  • In the future, if you could post these types of questions to the iRules forum, then, you'll likey get a quicker response.

     

    There are two types if url rewrites you can do with iRules. First a HTTP::redirect will issue a redirect HTTP response back to the browser. The browser will then in turn change the address bar and issue a new request. The following example will look for host requests to aaa.myzone.com and will issue a redirect to the browser keeping the URI intact but changing the host.

     

    when HTTP_REQUEST {  
     switch [HTTP::host] {  
     "aaa.myzone.com" {  
     HTTP::redirect "http://bbb.mynewzone.com[HTTP::uri]"  
     }  
     }  
     }

     

    Or, if you don't want to change the address bar, you can just modify the host value, you can do so with the following code

     

    when HTTP_REQUEST {  
     switch [HTTP::host] {  
     "aaa.myzone.com" {  
     HTTP::header replace "Host" "bbb.mynewzone.com"  
     }  
     }  
     }

     

    Hope this helps...

     

    -Joe
  • Joe,, when I drop your 1st code into my bip I get

     

    the following error,,

     

     

    01070151:3: Rule [joe-1st] error:

     

    line 1: [undefined procedure: HTTP::URI] [HTTP::URI]

     

  • It should be [HTTP::uri] instead of [HTTP::URI] - no caps.

     

     

    Denny
  • I "knew" that felt funny when I was typing it in. I guess I would have figured that it would be second nature to me by now. Sorry for the mixup.

     

     

    -Joe