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

habib_Khan's avatar
habib_Khan
Icon for Nimbostratus rankNimbostratus
Jul 21, 2016

Replace part of irule and irule applied doesnt work.

Hi All,

I have been trying to replace a part uri. Whenever request comes and URL has uri /sites/mkt/CPTeam/, it should be replaced with /sites/cbtit/. Tried below irules, doesnt work. Anything if i am missing. Only /sites/mkt/CPTeam/ should be replaced rest all uri should remain same.

http://mydocs.dcba.com/sites/mkt/CPTeam/default.aspx http://mydocs.dcba.cpm/sites/mkt/cpteam/_layouts/viewlsts.aspx http://mydocs.dcba.com/sites/mkt/cpteam/inn/SitePages/Home.aspx http://mydocs.dcba.com/sites/mkt/CPTeam/DOH/default.aspx

when HTTP_REQUEST { log local0. "Incoming URI = [HTTP::uri]" if { [HTTP::uri]] starts_with "/sites/mkt/cpteam/" } { set uri [string map -nocase {"/sites/mkt/cpTeam/" "/sites/cbtit/"} [HTTP::uri]] log local0. "New URI = $uri" HTTP::uri $uri } }

Irule 1: when HTTP_REQUEST { log local0. "Incoming URI = [HTTP::uri]"

if { [string tolower [HTTP::uri]] starts_with "/sites/mkt/CPTeam/" } {
    set uri [string map -nocase {"/sites/mkt/CPTeam/" "/sites/cbtit/"} [HTTP::uri]]
    log local0. "New URI = $uri"
    HTTP::uri $uri
}

}

Irule 2: when HTTP_REQUEST { log local0. "Incoming URI = [HTTP::uri]" if {[HTTP::uri] contains "/sites/mkt/CPTeam/"} { HTTP::uri [string map {"/sites/mkt/CPTeam/" "/sites/cbtit/"} [HTTP::uri]] log local0. "New URI = $uri" } }

Irule 3: when HTTP_REQUEST { if { [HTTP::uri] starts_with "/sites/mkt/CPTeam/"}{ HTTP::redirect "http://[string map {/sites/mkt/CPTeam/ /sites/cbtit/} [string tolower[HTTP::host]][HTTP::uri]]" } }

Irule 4: when HTTP_REQUEST { log local0. "Incoming URI = [HTTP::uri]" if { [HTTP::host] contains "mydocs.dcba.com/" } { if {[string tolower [HTTP::uri]] starts_with "/sites/mkt/CPTeam/" } { set newpath [HTTP::host][string map {"/sites/mkt/CPTeam/" "/sites/cbtit/"} [HTTP::uri]] log local0. "New URI = $uri" HTTP::redirect "http://$newpath" } } }

2 Replies

  • Hi,

    You have an error in your first irule :

    [string tolower [HTTP::uri]] starts_with "/sites/mkt/CPTeam/"

    should be replaced by

    [string tolower [HTTP::uri]] starts_with "/sites/mkt/cpteam/"

    because you added tolower.

  • when HTTP_REQUEST { if { [HTTP::uri] starts_with "/sites/mkt/CPTeam/"}{ HTTP::respond 302 Location "http://[string tolower [HTTP::host]][string map [list "/sites/mkt/CPTeam/" "/sites/cbtit/"] [HTTP::uri]]" Connection Close } }

     

    when url is requested http://mydocs.dcba.com/sites/mkt/cpteam ---- this is getting replaced with http://mydocs.dcba.com/sites/hiait But when below is requested there is no change. http://mydocs.dcba.com/sites/mkt/cpteam/_layouts/viewlsts.aspx but when request comes this way there is no change.

     

    url should change to http://mydocs.dcba.com/sites/cbtit/_layouts/viewlsts.aspx