tidenz_92110
Mar 24, 2010Nimbostratus
Location rewrite redirect 302 string issues
New to string commands and irules but i am trying to do a header replace without using regex.
In the redirect location header I am trying to strip out the protocol and the hostname to make the redirect relative to the application for testing
(yes i know the RFC is to have a FQDN in the location header) but the apps guys want it.
So the current location header looks like
http://company.com/app1/sad.do
i want
/app1/sad.do
note this will be used on multiple domains so it maybe company1 or company2 etc.
I have tried to read it into a variable and then use a findstr to find the first trailing slash but i keep matching the / in "http:/" is there a way to miss the first 2 // and find the last /
The irule is as follows
when HTTP_RESPONSE {
set newloc [HTTP::header Location]
log local0.debug "$newloc"
set rewriteloc [findstr $newloc "/" 9 ]
log local0.debug "$rewriteloc"
if { [HTTP::is_redirect] }{
HTTP::header replace Location "$rewriteloc"
}
Thanks