Forum Discussion
kc2kth_49679
Nimbostratus
17 years agoRewrite 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, then send a redirect back with the new host and uri. It seems I can't use string map to change the path and page name all at once since there is a slash separating the two. I suppose I could use two string maps, but I thought there was probably a better method I'm missing.
Here's the code I've done so far.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"app.domain.com" {
set host www.google.com
HTTP::uri [string map {"index.jsp" "index.asp"} [HTTP::uri]]
log local0. "redirecting to $host[HTTP::uri]"
HTTP::redirect http://$host[HTTP::uri]
}
}
}
7 Replies
No RepliesBe the first to reply
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