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

Jay_Ward_231434's avatar
Jay_Ward_231434
Icon for Nimbostratus rankNimbostratus
Jun 07, 2016

Passthough path and query/parameters, but redirect URL without path or query/parameters.

Hello,

 

I am looking for some iRule help. I need to be able to passthrough a URL to backend servers that has any path or parameters (this might be default, not sure). For example, https://myexample.com/path/go would be get passed through to backend servers.

 

If the request comes in without a path/query/paramters, for example it will get redirected to a different url, for example https://redirecturl.com

 

Thanks!

 

2 Replies

  • Try this (untested):

    when CLIENT_ACCEPTED {
        set DEFAULT_POOL [LB::server pool]
    }
    when HTTP_REQUEST {
        if { ( [string tolower [HTTP::host]] eq "myexample.com")} {
            if { not ([HTTP::uri] eq "/") } {
                HTTP::respond 301 Location "https://redirecturl.com/"
            } else {
                pool $DEFAULT_POOL
            }
        }
    
    }
    
  • Hi,

    Here an irule example :

    when HTTP_REQUEST {
        if { [HTTP::uri] eq "/" and [HTTP::query] eq "" } {
            HTTP::respond 301 Location "https://redirecturl.com/"
        }
    
    }