Forum Discussion
ant8344_5401
Nimbostratus
May 04, 2006http redirect rule while preserving the whole URI
Hello,
I have done simple redirects before but have never come across this request (which stumped me).
For instance, we have a redirect from http://www.cnn.com/abc going to http://www.cnn.com/xyz (that is the simple part).
Now we need to be able to preserve the entire URI when performing the redirect, for instance http://www.cnn.com/abc/bla/blaaf./bla.jsp will get redirected to http://www.cnn.com/xyz/bla/blaaf./bla.jsp.
So the path itself will stay the same other than (xyz instead of abc).
Is this at all possible in version 4.5(13), and if so can someone please post an example or shed some light on this matter?
Thanks
5 Replies
- Deb_Allen_18Historic F5 Account
This command will extract the trailing part of the URI:findstr(http_uri, '/abc', 4)
It's been a while since I played w/v4 rules, but I think you could then build the redirect as:redirect to "https://%h/xyz/(findstr(http_uri, '/abc', 4))"
(It passes the syntax check, but I seem to have a firewall blocking my attempt to push traffic through the virtual, so I can't verify if the findstr command is evaluating as expected within the context of the redirect.)
HTH
/deb - Martin_MachacekHistoric F5 AccountWell, the basic idea is good, but syntax is wrong. The correct syntax is:
redirect to "https://" + http_host + /xyz" + findstr(http_uri, "/abc", 4) - Deb_Allen_18Historic F5 Accountsweet, I figured that wasn't quite right. I forgot you have to isolate the findstr command like that... Thanks for straightening me out.
(One minor syntax correction - added missing ")redirect to "https://" + http_host + "/xyz" + findstr(http_uri, "/abc", 4) - Bobby_Glidwell_
Nimbostratus
I have a very similar situation and would like to apply a similar fix. However, when I attempt to use a "+" to concantenate strings together, I get an "Error 331835 -- Rule string to tree failed. - syntax error at '+'".
The exact rule is:
if (http_uri starts_with "/hlc/" and not (http_uri contains ".")) {
log "Good HIT"
redirect to "http://" + http_host + "/hlc/home.aspx?" + getfield(http_uri, "/" ,2)
}
Running 4.5PFT-03
Does 4.5 not support string contatenation using the "+"? - Deb_Allen_18Historic F5 AccountHi Bobby -
The rules syntax was changed in version 4.5 PTF-04 to limit strings to 63 characters, so support for string contatenation using the "+" might not have been added until then...
4.5.14 is the current maintenance release in the 4.x line, and has been out since January.
HTH
/deb
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