Forum Discussion
Leslie_South_55
Nimbostratus
Oct 19, 2007findclass AND external class AND wildcards
I am using an external class file to do URI redirects, when using speciffic URI matching it works fine: when HTTP_REQUEST {
log local0. "Uri is [HTTP::uri]"
set NewURI [findclass [HTTP::uri]...
Leslie_South_55
Nimbostratus
Oct 23, 2007I seem to be having an issue with the class. The file keeps getting un-formatted. I build the file like this:
"/test/google/" "http://www.google.com",
"/test/yahoo/" "http://www.yahoo.com",
"test/msn/" "http://www.msn.com",
"test/f5/" "http://www.f5.com",
"test/ask" "http://www.ask.com"
and after a b load, it looks like this
"/test/google/",
"/test/yahoo/",
"http://www.ask.com",
"http://www.f5.com",
"http://www.google.com",
"http://www.msn.com",
"http://www.yahoo.com",
"test/ask",
"test/f5/",
"test/msn/",
so when it gets to '[getfield $line " " 2]' there is no data; I changed the log statement for the "Matched:" to look like this
log local0. "Matched: [HTTP::path] to: [getfield $line " " 2]"
so I could see what is was trying to redirect to as I kept redirecting to the original PATH.
Here is the applied rule (again)
when HTTP_REQUEST {
log local0. "URI is [HTTP::uri]"
foreach line $::wwwredirects {
log local0. "Current line from the class: $line"
if {[HTTP::path] starts_with [getfield $line " " 1]}{
log local0. "Matched: [HTTP::path] to: [getfield $line " " 2]"
log local0. "getfield-1 is $line"
HTTP::redirect "[getfield $line " " 2]"
log local0. "redirecting to http://[HTTP::host][HTTP::uri]"
Return from the foreach loop once a match is found
return
}
}
and here is the log
Oct 23 11:52:57 tmm tmm[17883]: Rule rule_wwwredirecttest : URI is /test/google/
Oct 23 11:52:57 tmm tmm[17883]: Rule rule_wwwredirecttest : Current line from the class: /test/google/
Oct 23 11:52:57 tmm tmm[17883]: Rule rule_wwwredirecttest : Matched: /test/google/ to:
Oct 23 11:52:57 tmm tmm[17883]: Rule rule_wwwredirecttest : getfield-1 is /test/google/
Oct 23 11:52:57 tmm tmm[17883]: Rule rule_wwwredirecttest : redirecting to http://newtest.domain.com/test/google/
As I mention above, there is no value for getfield 2, since the class file format does not stay the way I create it...how should I edit the file so the format does not change? If I don't b load, the file format is fine.
Thanks
-L
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
