Forum Discussion

walt_97468's avatar
walt_97468
Icon for Nimbostratus rankNimbostratus
Dec 02, 2008

302 redirect string capture and replace

I have modified a previous post for this irule:

 

 

when HTTP_REQUEST {

 

HTTP::header replace "Host" "www.test.com"

 

}

 

when HTTP_RESPONSE {

 

HTTP::header replace "Host" "www.test2.com"

 

if { [HTTP::status] starts_with "3"} {

 

if { [HTTP::header location] contains "http://www.redirect.com/" } {

 

set newLoc [string map {www.redirect.com www.test2.com} [HTTP::header location] ]

 

HTTP::header replace location "$newLoc"

 

}

 

}

 

}

 

 

 

We are replacing the host for both requests and responses. Also,when a server sends a 302 response (and I also want to look for 301's), the response includes a location field. A packet capture shows that the loaction field is set to "http://www.redirect.com"

 

 

All I need to do is to change www.redirect.com to www.test2.com, and leave the rest of the URI intact. Am I going about this the right way?

 

 

Thanks for your help!

 

6 Replies

No RepliesBe the first to reply