Forum Discussion

Ankur_5273's avatar
Ankur_5273
Icon for Nimbostratus rankNimbostratus
Jun 12, 2014
Solved

Rewrite the content in URI with a short URL

Hi Experts

 

I need assistance on shortening of URL as follows

 

If a web page with following Source URL is browsed , then a part of URI (highlighted in bold) should be converted to "en" (which is English language ) and output should be Masked URL as shown below .

 

Source URL : http://hostname/secureapp/connect/report_en/REP/XYZ

 

Masked URL : http://hostname/en/XYZ

 

Regards, Ankur

 

  • I am unable to update my original post. Here is an updated version.

    If you simply want to mask URL's then apply a STREAM profile with the following iRule.

    when HTTP_REQUEST {
      log local0. "..in HTTP_REQUEST"
    
       no replacement for requests
      STREAM::disable
       disable compression server side
      HTTP::header remove "Accept-Encoding"
    }
    when HTTP_RESPONSE {
      log local0. "...in HTTP_RESPONSE"
    
       only replace text content
      if {!([HTTP::header value Content-Type] contains "text")}{ return}
    
      set search ""
      foreach pair [class get myclass] { 
        set search "$search@[lindex $pair 0]@[lindex $pair 1]@"
      }
      log local0. "String replace=$search"
      STREAM::expression $search
      STREAM::enable
    }
    

    Then create a string data class myclass as follows...

    Name                                      Value
    /secureapp/connect/report_en/REP   /en
    /peter                             /pan
    

    And get the following output from a logs

    Rule /Common/myrule : ...in HTTP_REQUEST
    Rule /Common/myrule : ...in HTTP_RESPONSE
    Rule /Common/myrule : search=@/secureapp/connect/report_en/REP@/en@@/peter@/pan@
    

    And the resulting web page...

    It works!
    
    /en
    /pan
    

22 Replies