Forum Discussion
CraigyB_172365
Nimbostratus
Jan 12, 2018HOST and partial path rewrite
Hi I am new to F5 and am trying to do a URL rewrite a chunk of the URL. I think I am on the right track but I just cannot make it work. Any help is really appreciated.
I just want to replace any...
kolom_265617
Cirrostratus
Jan 12, 2018Hello CraigyB, Try using the following iRule.
when HTTP_REQUEST {
if { ( [string tolower [HTTP::uri]] starts_with "/info" ) } {
set uri [HTTP::uri [string map {"/info" "/files"} [HTTP::uri]]]
HTTP::redirect "https://[HTTP::host]$uri"
}
}
- CraigyB_172365Jan 12, 2018
Nimbostratus
Hi Kolom, appreciate your input, which parts do i replace with destination host name and port number?
- kolom_265617Jan 12, 2018
Cirrostratus
i've tested the following and it's working fine.
when HTTP_REQUEST if { ( [string tolower [HTTP::uri]] starts_with "/info" ) } { set newUri [string map [list "info" "files"] [HTTP::uri]] HTTP::redirect "http://[HTTP::host]$newUri" }if you want to replace the host/port , change the redirection part from HTTP::redirect "http://[HTTP::host]$newUri" to HTTP::redirect "http://10.10.10.10:9000$newUri"
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects