Forum Discussion

Mike_Pones_6391's avatar
Mike_Pones_6391
Icon for Nimbostratus rankNimbostratus
Jun 01, 2006

HTTP_URI Lookup Problem

I currently have a rule setup to look for the word "ecommerce" and then make a redirect to HTTPS. Here is the rule:

 

 

if (http_uri contains "ecommerce") {

 

redirect to "https://%h/%u"

 

}

 

 

But what I am looking to do is ONLY have it look past the domain name, for example "http://www.myurl.com/ecommerce". But it is actually redirecting even if "ecommerce" is anywhere in the URL. Like "http://www.myurl.com/um/user/showUserRegister.do?hello=ecommerce". How can I ONLY have it look directly after the domain?

 

 

Thanks,

 

 

Mike
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Hi Mike -

    You can use the "getfield" function to split the URI string into 2 parts, split on the "?" character:
    if (getfield (http_uri, '?', 1) contains "ecommerce") {
    redirect to "https://%h/%u"
    }

    (v9 introoduced a new command "HTTP::path" to extract only the URI path & filename without the trailing query parameters)

    HTH

    /deb
  • deb, thanks for the quick reply.

     

     

    Since I an not too familier with url "stuff". Why would you chose to split it at the "?", is that common?

     

     

    Thanks,

     

     

    Mike
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Generic URI syntax uses the ? character to delimit the start of the query string.

    By splitting on the ?, you create 2 fields: the part before the ?, which is the actual resource being requested; and the part after the ?, which contains the query.

    From RFC 3986 (URI Generic Syntax): Example URI with component parts:
    http://www.example.com:8042/over/there?name=ferretnose
    \__/   \__________________/\_________/ \_________/ \___/
      |             |              |            |        |
    scheme      authority         path       query    fragment