Forum Discussion
hkr_36676
Nimbostratus
Mar 04, 2008Using "switch" instead of "if"
Hi
I have made this script to remove "ndk_webste" in links
on Google.
It uses a Data_Group "map_website", to make a 301 redirect.
when HTTP_REQUEST {
/ndk_we...
The_Bhattman
Nimbostratus
Mar 04, 2008I believe your code would like something like the following:
when HTTP_REQUEST {
/ndk_website/npsportal/cmsdoc.nsf/WebDoc/ndkw73fh32
$website == /npsportal $index == /cmsdoc.nsf/WebDoc/ndkw73fh32
switch -glob [HTTP::uri] {
"*ndk_website*" {
regexp {/ndk_website/[^/]+]} [HTTP:uri] website
regexp {(?:/cms)([^?]+)} [HTTP::uri] index
set redirect_map [findclass $website $::map_website " "]
HTTP::respond 301 Location "http://$redirect_map$index"
}
}
}
Also, I would try to replace the regexp because it evaluates much slower. Try looking at scan or findstr commands.
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