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

Glenn_Ruffus_10's avatar
Glenn_Ruffus_10
Icon for Nimbostratus rankNimbostratus
Mar 06, 2014

HTTP redirects with data group list

I need to perform many HTTP 302 redirects on one virtual server and would like to have a single iRule that calls on a single string type data group list to get the URLs to redirect to. In this particular case, they are all HTTP (no HTTPS) but it would be nice to have the flexibility of redirecting to a HTTPS URL. The logic that I am thinking of is:

 

Data group list "HTTP_redirects_list": String: somehost.com Value:http://www.someotherhost.com/this/that/otherthing ...

 

iRule: When HTTP_REQUEST if the URL matches a string found in the "HTTP_redirects_list" data group list then redirect to the related value found in the "HTTP_redirects_list" data group list else do nothing.

 

Thanks for your assistance

 

1 Reply

  • I think you are looking for something like this:

    when HTTP_REQUEST {
        Use [HTTP::path] or [HTTP::uri] depending on your needs
       set REQUEST [HTTP::path] 
       if { [class match $REQUEST equals HTTP_redirects_list] } {
          set REDIRECT [class match -value -- $REQUEST equals HTTP_redirects_list]
          HTTP::redirect $REDIRECT
       }
    }

    edit: sorry about the formatting