Forum Discussion

Mike_Roe_60070's avatar
Icon for Nimbostratus rankNimbostratus
Feb 18, 2011

URL and 301 Re-Write

Hi All, Im hoping someone can help me out. I have a need to have one site (which has SSO with APM) be known in the world as 8. In this instance the site has an SSO profile that is tied to the domain name but, by way of another virtual in front of it I need addresses look like “” and “”. So for the SSO to work I have to replace the host which I have been able to do like this:





HTTP::header replace Host ""


virtual my_jboss_sb_vs





I think I have this part working but, in the response I am getting 301’s and it is breaking the solution. Im guessing I can use HTTP::header is_redirect which I found in my searching but, im not sure how to get it done.



In a netshell this is needed because all of our apps run on 1 domain “” but, our company is known by many names/domains. We need our customers to think they are on the name they are familiar with throughout their web session so If they come to they dont get a redirect to But in actuality they are using the app at the address



Thanks in advance



2 Replies

  • Hi Mike,



    You could use the full ProxyPass iRule to rewrite the external hostname to the internal one on requests and "undo" the rewriting on response headers and/or payload.





    Or you could use a simplified version. This post has a 9.x example, but it could be updated fairly easily for 10.x.





  • Thnaks Aaron, I had just gotten something similar working as you were replying.

    set sid [ACCESS::session data get "session.keydb"]
            HTTP::cookie insert name "MRHSession" value "$sid"
     when HTTP_REQUEST { 
    set origHeader [HTTP::header Host]
     log local0. "Origional header value: $origHeader"
        HTTP::header replace Host "" 
     log local0. "New header value: [HTTP::header Host]"
    virtual my_jboss_sb_vs
    when HTTP_RESPONSE {
    if { [HTTP::is_redirect] } {
          if { [HTTP::header Location] contains "" } {
             log local0. "Original Location value: [HTTP::header Location]"
            HTTP::header replace Location [string map -nocase {} [HTTP::header value Location]]
     log local0. "New Location value: [HTTP::header Location]"

    This works but it will only work for 1 out of 8 domains. What I mean is that since I have the SSO in play which i believe uses the MRHSession that is set in the ACCESS_ACL_ALLOWED section I need to reuse the same MRHSession when I change domains. In this rule my goal is to be able to type * or * and either way i get to

    Im thinking I can do it if I can switch out the domain on the way in and out but i cant figure out how to let the response know what the hostname was in the origional request.

    Hope this makes sense.