How to evaluate url search request

Hi i have a problem i need to resolve, whereby i need to filter search requests looking for requests that contain less than 3 characters and if they do

return a standard search result.

An example is below of a search request is below:-

http://test.domain.com:9999/RTEFacade\_RIGHTV/SearchVideos?

client=xml&expression=The&field_name=name&identity=5BTWmZd8VMc88GDqunvytFa%2B%2FA4kIu9kXhHL27Iwje%2

BVsrpnZmwDn5jZj7VbrHEDiinYpfiIZvwVXDD2pjxJwUv96uPxwHx6c66EVFxL0cGCvplvCQUKyAxsmKyFH28eNErrR1OREweC

Nzk6m2JLYFS3C0Me5hLf&language_code=sv&limited=false&match_partial=true&max_results=30&root_id=605&securit

y=false

The field that i need to look at is marked in bold above, is this has less than 3 characters then we need to return the following url instead

http://test.domain.com:9999/SearchVideos/Result.html

Any ideas how i would achieve this ?

/Regards Craig

This shouldn’t be too hard, when you say you want to ‘return the following URL instead’ do you mean send a redirect?

No not a redirect, it would be the case that the other search url is sent instead of the original one, but only when there are matching citeria (i.e only 3 characters or less in the mare marked with bold text)

/Craig

OK, so if it’s not a redirect, how do you want to ‘send’ the URL? Do you want the F5 to respond with the web page? Or do you want to modify the request sent to the server so it returns something specific?

We have to modify the request puting this in its place:- http://test.domain.com:9999/SearchVideos/Result.html /Craig

OK, understood. So here’s what I think will work;

when HTTP_REQUEST {
 Check if the path is the one used for search queries (and ignore case)
 if { [string tolower [HTTP::path]] equals "/rtefacade_rightv/searchvideos" } {

  Look for text 'expression' in the URI , skip forward 1 character (the '=')
  and save all text up to the next '&' in variable 'searchstring'
  set searchstring [findstr [HTTP::uri] "expression" "1" "&"]
  
  If the length of 'searchstring' is 3 or less, change the URI sent
  to the real server
  if { string length $searchstring <= 3 } {
   HTTP::uri "/SearchVideos/Result.html"
   
   Stop processing the iRule here
   return
  }
 }
}

The only bit I’m unsure about is this line, might need some square brackets??? ‘if { string length $searchstring <= 3 } {’

Note all '&'s should be just &

Okay thanks a lot i will try it out and let you know the results /Craig

Please do, cheers.

just another example.

[root@ve10:Active] config  b virtual bar list
virtual bar {
   snat automap
   pool foo
   destination 172.28.19.252:9999
   ip protocol 6
   rules myrule
   profiles {
      http {}
      tcp {}
   }
}
[root@ve10:Active] config  b pool foo list
pool foo {
   members 200.200.200.102:80 {}
}
[root@ve10:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
  set param [URI::query "?&[HTTP::query]" expression]
  if {$param ne "" and [string length $param] < 3} {
    HTTP::uri "/SearchVideos/Result.html"
  }
}
}

 expression=The

[root@ve10:Active] config  ssldump -Aed -nni 0.0 port 9999 or port 80
New TCP connection 2: 172.28.19.251(45999) <-> 172.28.19.252(9999)
1360713613.2265 (0.0010)  C>S
---------------------------------------------------------------
HEAD /RTEFacade_RIGHTV/SearchVideos?client=xml&expression=The&field_name=name&identity=5BTWmZd8VMc88GDqunvytFa%2B%2FA4kIu9kXhHL27Iwje%2BVsrpnZmwDn5jZj7VbrHEDiinYpfiIZvwVXDD2pjxJwUv96uPxwHx6c66EVFxL0cGCvplvCQUKyAxsmKyFH28eNErrR1OREweCNzk6m2JLYFS3C0Me5hLf&language_code=sv&limited=false&match_partial=true&max_results=30&root_id=605&security=false HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: test.domain.com

---------------------------------------------------------------

New TCP connection 3: 200.200.200.10(45999) <-> 200.200.200.102(80)
1360713613.2288 (0.0010)  C>S
---------------------------------------------------------------
HEAD /RTEFacade_RIGHTV/SearchVideos?client=xml&expression=The&field_name=name&identity=5BTWmZd8VMc88GDqunvytFa%2B%2FA4kIu9kXhHL27Iwje%2BVsrpnZmwDn5jZj7VbrHEDiinYpfiIZvwVXDD2pjxJwUv96uPxwHx6c66EVFxL0cGCvplvCQUKyAxsmKyFH28eNErrR1OREweCNzk6m2JLYFS3C0Me5hLf&language_code=sv&limited=false&match_partial=true&max_results=30&root_id=605&security=false HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: test.domain.com

---------------------------------------------------------------

 expression=A

[root@ve10:Active] config  ssldump -Aed -nni 0.0 port 9999 or port 80
New TCP connection 1: 172.28.19.251(46000) <-> 172.28.19.252(9999)
1360713726.9737 (0.0010)  C>S
---------------------------------------------------------------
HEAD /RTEFacade_RIGHTV/SearchVideos?client=xml&expression=A&field_name=name&identity=5BTWmZd8VMc88GDqunvytFa%2B%2FA4kIu9kXhHL27Iwje%2BVsrpnZmwDn5jZj7VbrHEDiinYpfiIZvwVXDD2pjxJwUv96uPxwHx6c66EVFxL0cGCvplvCQUKyAxsmKyFH28eNErrR1OREweCNzk6m2JLYFS3C0Me5hLf&language_code=sv&limited=false&match_partial=true&max_results=30&root_id=605&security=false HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: test.domain.com

---------------------------------------------------------------

New TCP connection 2: 200.200.200.10(46000) <-> 200.200.200.102(80)
1360713726.9756 (0.0017)  C>S
---------------------------------------------------------------
HEAD /SearchVideos/Result.html HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Accept: */*
Host: test.domain.com

---------------------------------------------------------------

Just to let you know the irule worked without prolems.

/regards Craig

Just to let you know the irule worked without problems.

/regards Craig

Which one did you use?