Forum Discussion

kc2kth_49679's avatar
kc2kth_49679
Icon for Nimbostratus rankNimbostratus
17 years ago

Rewrite 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