Forum Discussion

Vince_Beltz_959's avatar
Vince_Beltz_959
Icon for Nimbostratus rankNimbostratus
Jul 31, 2009

Findstr in Redirect?

Seems like this should be very simple. If a certain value is in the HTTP::host, I need to search the URI for a string and do a redirect with the found string on the end of the redirected URI. If the HTTP::host value isn't there, the rule falls through to a standard redirect. Is there a way to simply do the findstr within the redirect, something like this:

 

when HTTP_REQUEST {

 

If {[HTTP::host] ends_with "sub.domain.com" } {

 

HTTP::redirect http://target.com/domain=([findstr] [HTTP::uri] "q=" 2 "&")

 

else

 

HTTP::redirect http://target.com/domain=[HTTP::host]

 

}

1 Reply

  • The rule you posted looks find. Just change the braces slightly:

     

     

    [findstr [HTTP::uri] "q=" 2 "&"]

     

     

    Or you could use [URI::query [HTTP::query] "q"] to get the value of the q parameter (Click here).

     

     

    Aaron