Forum Discussion

Johan_Van_Geste's avatar
Johan_Van_Geste
Icon for Nimbostratus rankNimbostratus
Apr 12, 2006

URL Rewrite/Redirect

Dear All,

 

 

we currently have a customer that would like to do the following with iRules: an application-server is listening on http://server/app/ for requests. We'd like to have end-users connecting to http://server and end up on the /app/ page without the end-users having to input this portion.

 

 

Is this something that can easily be realised through iRules?

 

 

Thanks for your help,

 

 

Johan.
  • You can use the "HTTP::uri" command to change the uri that is sent to the backend server. It's easy to change the uri, but it's the side cases that you'll want to account for. This iRule will convert "http://server/" into "http://server/app/" but will not do it for "http://server/foo".

    when HTTP_REQUEST {
      if { [HTTP::uri] equals "/" } {
        HTTP::uri "/app/"
      }  
    }

    I'm not sure if your application supports GET parameters but that could be an issue as well that you want to take into account. This iRule will add "/app/" to the start of all uri's that don't begin with "/app/".

    when HTTP_REQUEST {
      if { ! [HTTP::uri] starts_with "/app" } {
        set olduri [HTTP::uri]
        HTTP::uri "/app$olduri"
      }
    }

    That may be more what you are looking for. You'll have to play around with the logic to determine all your corner cases.

    -Joe
  • Thanks Joe, these things did the trick in an easy way ...

     

     

    Kind regards,

     

     

    Johan.