Forum Discussion
Puli
Nimbostratus
Sep 11, 2012Match and split a URI
How can i match and split a URI,
like below, eg :
http:/abc.com/about/communityprocess/maintenance/JMF2.0/$
re-direct to
abc.com/landingpage/$1
For example
http:/abc.com...
hoolio
Cirrostratus
Sep 11, 2012You could use a switch statement for this. You can try something like this:
when HTTP_REQUEST {
log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] to [HTTP::host][HTTP::uri]"
switch -glob [string tolower [HTTP::uri]] {
"/about/communityprocess/maintenance/JMF2.0/hello.html" {
log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to http://abc.com/landingpage/hello.html"
HTTP::redirect "http://abc.com/landingpage/hello.html"
}
"/about/communityprocess/*" {
log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting to http://abc.com/landingpage/"
HTTP::redirect "http://abc.com/landingpage/"
If you need to take part of the original URI and include it in the redirect, you can use getfield to split it:
HTTP::redirect "http://abc.com/landingpage/[getfield [HTTP::uri] "/about/communityprocess/" 2]"
}
}
}
Aaron
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