Need to replace part of uri in url. Tried many irules
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
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 { if {[HTTP::uri] contains "/sites/mkt/CPTeam/"} { HTTP::uri [string map {"/sites/mkt/CPTeam/" "/sites/cbtit/"} [HTTP::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" } } }