For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

JPONNUSAMY_2705's avatar
JPONNUSAMY_2705
Icon for Nimbostratus rankNimbostratus
Jul 31, 2016

iRule to hide Query String from URL

Dear F5 Experts,

 

I am new to F5, We have requirement that we want hide query string externally for End-user, but internally it should use and send request to webServer. Our F5 Team is not aware of to deal with dynamic contents.

 

Actual URL: http://cmspweb.com/sites/en_US/about/newsroom?year=2015&month=5

 

Expecting URL: http://cmspweb.com/sites/en_US/about/newsroom/2015/5

 

Note: Here Year & Month values are dynamic, currently we have years from 2008 to 2016 and months 1 to 12. We were tried lot from WebServer level but didn't help. Our F5 team will update the iRule which we have given. So, Kindly please provide iRule to resolve this issue.

 

Thanks

 

Jayaram

 

6 Replies

  • Hi,

    The below irule can change URI like

    /sites/en_US/about/newsroom/year/month
    to
    /sites/en_US/about/newsroom?year=year&month=month

    when HTTP_REQUEST {
        set path [HTTP::path]
        if { $path starts_with "/sites/en_US/about/newsroom/" and [URI::path [HTTP::uri] depth] eq "5" } {
            set year [getfield $path "/" 6]
            set month [getfield $path "/" 7]
            set path [URI::path [HTTP::uri] 1 4]
            HTTP::uri "$path?year=$year&month=$month"
        }
    }
    
    • JPONNUSAMY_2705's avatar
      JPONNUSAMY_2705
      Icon for Nimbostratus rankNimbostratus

      Dear Friend,

       

      Actually I am looking the iRule for changing the URL from /sites/en_US/about/newsroom?year=year&month=month to /sites/en_US/about/newsroom/year/month (Reverse)

       

      Kindly please share for the same.

       

    • Yann_Desmarest_'s avatar
      Yann_Desmarest_
      Icon for Nacreous rankNacreous

      Hi,

      Sorry I misunderstood your requirement. Please find below an example of translating the uri the way you want :

          when HTTP_REQUEST {
              set path [HTTP::path]
              if { $path eq "/sites/en_US/about/newsroom" and [HTTP::uri] contains "year=" and [HTTP::uri contains "month=" ] } {
                  set year [URI::query [HTTP::uri] "year"]
                  set month [URI::query [HTTP::uri] "month"]
                  HTTP::uri "$path/$year/$month"
              }
          }
      
  • Hi,

    The below irule can change URI like

    /sites/en_US/about/newsroom/year/month
    to
    /sites/en_US/about/newsroom?year=year&month=month

    when HTTP_REQUEST {
        set path [HTTP::path]
        if { $path starts_with "/sites/en_US/about/newsroom/" and [URI::path [HTTP::uri] depth] eq "5" } {
            set year [getfield $path "/" 6]
            set month [getfield $path "/" 7]
            set path [URI::path [HTTP::uri] 1 4]
            HTTP::uri "$path?year=$year&month=$month"
        }
    }
    
    • JPONNUSAMY_2705's avatar
      JPONNUSAMY_2705
      Icon for Nimbostratus rankNimbostratus

      Dear Friend,

       

      Actually I am looking the iRule for changing the URL from /sites/en_US/about/newsroom?year=year&month=month to /sites/en_US/about/newsroom/year/month (Reverse)

       

      Kindly please share for the same.

       

    • Yann_Desmarest's avatar
      Yann_Desmarest
      Icon for Cirrus rankCirrus

      Hi,

      Sorry I misunderstood your requirement. Please find below an example of translating the uri the way you want :

          when HTTP_REQUEST {
              set path [HTTP::path]
              if { $path eq "/sites/en_US/about/newsroom" and [HTTP::uri] contains "year=" and [HTTP::uri contains "month=" ] } {
                  set year [URI::query [HTTP::uri] "year"]
                  set month [URI::query [HTTP::uri] "month"]
                  HTTP::uri "$path/$year/$month"
              }
          }