Forum Discussion
Dan44
Altostratus
Nov 22, 2019URL Rewriting
Hello together Does anyone have experience with URL rewriting wit help of an iRule or a rewrite profile? For a migration i have to rewrite a url. We have two pools (old-web, new-web) containing IIS...
gersbah
Cirrostratus
Nov 22, 2019I have no experience with rewrite profiles, but I may be able to help with that iRule.
Your condition only matches when the path equals /webapp/, but you want it to match when it starts_with.
Then after that it would rewrite the entire url to "/", not just remove the /webapp/ portion of the path.
Instead you should be able to almost 1:1 use this example from here https://devcentral.f5.com/s/articles/irules-101-14-tcl-string-commands-part-2
when HTTP_REQUEST {
set uri [HTTP::uri]
if { $uri starts_with "/axess2" } {
HTTP::uri [string range $uri 7 end]
pool pool1
}
}
Adjusted to your own example:
when HTTP_REQUEST {
set uri [HTTP::uri]
if {[string tolower [HTTP::host]] eq "www.myweb.com" && [string tolower $uri] starts_with "/webapp/"} {
HTTP::header replace Host "app.myweb.com"
HTTP::uri [string range $uri 7 end]
pool new-web
}
}
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