Forum Discussion
kc2kth_49679
Nimbostratus
Feb 06, 2009Rewrite host and URI, then redirect
I thought I was pretty close on this one, but I can't quite get it to work. I need to rewrite a portion of a URI (drop part of the path and change the name of the page), change the host name, t...
hoolio
Cirrostratus
Feb 06, 2009That's a good start. You can do pairs of replacements within string map (Click here😞
string map {find1 replace1 find2 replace2} [HTTP::uri]
You don't need the -glob flag on switch if you're not using wildcards in the switch cases. You skip the intermediate variable for $host. And HTTP::uri is cached in the event, so logging it after modifying it won't show the change.
when HTTP_REQUEST {
switch [string tolower [HTTP::host]] {
"app.domain.com" {
log local0. "redirecting to http://www.google.com[string map -nocase {"/path_to_replace" "/new_path" "index.jsp" "index.asp"} [HTTP::uri]]"
HTTP::redirect "http://www.google.com[string map -nocase {"/path_to_replace" "/new_path" "index.jsp" "index.asp"} [HTTP::uri]]"
}
}
}
Aaron
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