Forum Discussion

Brendan_Newell_'s avatar
Brendan_Newell_
Icon for Nimbostratus rankNimbostratus
Sep 12, 2005

uri rewrite rule

If anyone can provide any assistance with the following then it would be much appreciated:

 

 

I have a customer who wants an irule to rewrite the uri so that when the user connects to the virtual server, they are passed through to the backend host with a slightly different uri.

 

 

eg.

 

 

user connects to http://www.virtualserver.com/test/index.html

 

user is directed to http://www.backendhost.com/sample/test/index.html

 

 

 

Many thanks!

6 Replies

  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    So you're looking for something like this, I believe:

    
    when HTTP_REQUEST {
      if{([HTTP::host] equals "virtualserver") and ([HTTP::uri] contains "test")} {
        HTTP::redirect "http://www.backendhost.com/sample[HTTP::uri]"
      }
    }
    -Colin
  • Colin,

     

     

    I don't think he is looking for a redirect... It seems he is looking for a transparent URI rewrite:

     

     

    HTTP::uri "sample[HTTP::uri]"

     

     

    Cheers,

     

    Brian
  • Many thanks guys, we have actually solved this now - I didnt think anyone was reading this thread so I didnt update it.

     

    Cheers anyway :-)
  • You can use the HTTP::uri command to change the URI passed to the backend server.

     

     

    Check out my blog post covering this one:

     

     

    http://devcentral.f5.com/weblogs/joe/archive/2005/07/27/ModifyingUriWithoutRedirect.aspx

     

    Click here

     

     

    -Joe
  • Hi Don,

     

     

    Can you enable debug on the iRule and post the anonymized logs from /var/log/ltm for a request to the home page and the following references? Can you use a browser plugin like HttpFox for Firefox or Fiddler for IE to see what is wrong with the image references?

     

     

    Aaron