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

PSritaC's avatar
PSritaC
Icon for Altostratus rankAltostratus
Feb 19, 2020

Redirection iRule Request for subsites

Hello

 

I am pretty new to F5 and would like to see if someone can help me with a redirection iRule.

 

The redirection should retain path after the second location or the subsites. So I am looking for something like:

1. when going to http://abcsp/sites/apps should be redirected to https://apps.abcsharepoint.example.com/

2. when going to http://abcsp/sites/apps/SomethingSomething should be redirected to https://apps.abcsharepoint.example.com/SomethingSomething

3. when going to http://abcsp/Anythingotherthansites should be redirected to https://abcsharepoint.example.com/

 

What I have in place right looks something like this:

 

when HTTP_REQUEST {

switch -glob [string tolower [HTTP::host]] {

"abcsp" {

if { [HTTP::uri] starts_with "/sites/apps/" } {

HTTP::redirect "https://apps.abcsharepoint.example.com/"

}

elseif { [HTTP::uri] starts_with "/" } {

HTTP::redirect "https://abcsharepoint.example.com/"

}

}

}

}

 

This is doing only 1 and 3. 2 is missing... 

 

Thanks in advance!

2 Replies

  • So if you want to do this programmatically then you need to retrieve the parts of the path. To do that, use the command [ getfield [HTTP::path] "/" <field number> ] getfield HTTP::path. You can also use the tcl split command to split the path into a list and check the list contents with lindex

    Seems pretty simple - the pseudocode would be:

    if field 2 == "sites"
        if field 3 != ""
            then Host = field 3.blahblah.com
        endif
        if field 4 != ""
            then new URI = /field3
        endif
        redirect to $Host$URI
    else
        redirect to other page
    endif

    Hopefully you can work it out from this