Forum Discussion

Anish_Srivastav's avatar
Icon for Nimbostratus rankNimbostratus
Nov 01, 2010

Need help with parsing URI




I have a bunch of URI's in our application like the following



I would like to do a redirect using iRules to eliminate the first directory "/wiki"



so if a request comes to it should 301 to and so on....



Can some one please help me?








2 Replies

  • Hi Anish,

    You can trim off the /wiki using string range:

    when HTTP_REQUEST {
        Check if URI starts with /wiki/
       if {[HTTP::uri] starts_with "/wiki/"}{
           Send a local redirect without the /wiki string
          HTTP::respond 301 Location [string range [HTTP::uri] 5 end]