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

fasteddye's avatar
fasteddye
Icon for Nimbostratus rankNimbostratus
Feb 22, 2019

redirect that also appends uri

We have some web servers behind a VIP that host several sites and use an irule for redirects to proper web site. We are adding a 3rd site that to these web servers and it requires a little bit of a different redirect. We need to be able to redirect the 3rd site by Host + file_path + URI. It needs to be able to append the URI to the end of the redirect.

 

All 3 redirects do redirect and the first 2 are working as they should. The 3rd redirect does redirect but it needs the ability to append the URI.

 

The 3rd redirect below is the one I am trying to have the URI appended to end of redirect if possible.

 

iRule I have been working with below.

 

when HTTP_REQUEST { if { ([HTTP::host] equals "web1.abc.com") && ([HTTP::uri] == "/") } { HTTP::redirect "; } elseif { ([HTTP::host] equals "web1.web.abc.com") && ([ HTTP::uri] == "/") } { HTTP::redirect "; } elseif { ([HTTP::host] equals "web2.abc.com") && ([ HTTP::uri] == "/") } { HTTP::redirect ";} }

 

I fumble my way around iRules so thank you very much in advance for recommendations or suggestions.

 

Thanks.

 

1 Reply

  • Prepared as per above comments. Try below iRule, Hope It will solved issue.

        when HTTP_REQUEST { 
            if { ([HTTP::host] equals "web1.abc.com") && ([HTTP::uri] == "/") } 
                { HTTP::redirect "https://web1.abc.org/web1" } 
            elseif { ([HTTP::host] equals "web1.web.abc.com") && ([ HTTP::uri] == "/") } 
                { HTTP::redirect "https://web1.web.abc.com/web" } 
            elseif { ([HTTP::host] equals "web2.abc.com") && ([ HTTP::uri] == "/") } 
                { HTTP::redirect "https://web2.abc.com/file_path[HTTP::uri]" } }
    

    OR

        when HTTP_REQUEST { 
        if { [HTTP::uri] equals "/"} {
        switch [string tolower [HTTP::host]] {
            "web1.abc.com" {HTTP::redirect "https://web1.abc.org/web1" }
            "web1.web.abc.com" {HTTP::redirect "https://web1.web.abc.com/web" }
            "web2.abc.com" {HTTP::redirect "https://web2.abc.com/file_path[HTTP::uri]"}
                }
         }
    }