Forum Discussion

eesgro_26208's avatar
eesgro_26208
Icon for Nimbostratus rankNimbostratus
Aug 12, 2010

URI rewrite question

To all,

 

 

I am no means an iRule programmer. I a merely an administrator of the LTM.

 

 

Anyhow here is my situation.

 

 

We have a website that people access via dummywebsite.com/uri/moreuri/evenmoreuri/default.htm

 

 

I need the F5 to redirect the client to www.dummywebsite.com/uri/moreuri/evenmoreuri/default.htm

 

 

I have read through some posts and determined it sounds more like a header rewrite and based off of those various posts compiled the following iRule. Is this accurate for what I am trying to achieve?

 

 

when HTTP_REQUEST {

 

if {[HTTP::header] eq "dummywebsite.com"}{

 

HTTP::header replace "www.dummywebsite.com"

 

}

 

}

 

 

Thank you! Ed

 

3 Replies

  • This is how I'd do it:

    
    when HTTP_REQUEST {
    if { [HTTP::host] eq "dummywebsite.com" } {
    HTTP::redirect "http://www.[HTTP::host][HTTP::uri]" }
    }
    

    I think you can use [HTTP::host] from within the HTTP::redirect event...if you can't, the following should work:

    This is how I'd do it:

    
    when HTTP_REQUEST {
    if { [HTTP::host] eq "dummywebsite.com" } {
    HTTP::redirect "http://www.dummywebsite.com[HTTP::uri]" }
    }
    

    In your example, you're replacing a header on the way to the server...and you'd have to specify that it's the "host" header that you want to rewrite.

  • It very well could be, I do not know. I am sure there is an RFC out there that recommends it SHOULD be treated as lower case... I don't think it is much of a performance hit in my environment so I turn it on to be safe. I use it a lot when I am working on URI's as well.
  • Posted By naladar on 08/13/2010 06:56 AM

     

    It very well could be, I do not know. I am sure there is an RFC out there that recommends it SHOULD be treated as lower case... I don't think it is much of a performance hit in my environment so I turn it on to be safe. I use it a lot when I am working on URI's as well.

     

     

    Almost certainly a good idea! I just happened to run into it once when I was entering capital letters in my browser and had my iRule looking for them...turns out the rule never saw the capital letter because the browser (or something else) was lowering them before it got to me.