Forum Discussion
DM_5174
May 19, 2011Nimbostratus
Multiple URI matching redirect
Hi All,
I was trying to accoplish the following things using a class or "string tolower" one-on-one matching to redirect the URI.
Can anyone please help or could suggest the best way to accomplish this? Site: http://www.mysite.com/old-service/old-app1 Objective:
1. rewrite the URI matching parameter defined in the class or use string tolower list if possible.
2. How do I match it where /old-service/old-app1 gets replaced with /new-service/new-app100 and so on...
*** (it needs to match exactly from the old URI to new URI) ***
Example: http://www.mysite.com/old-service/old-app1 ==> http://www.mysite.com/new-service/new-app100
Example: http://www.mysite.com/old-service/old-app2 ==> http://www.mysite.com/new-service/new-app200
Example: http://www.mysite.com/old-service/old-app3 ==> http://www.mysite.com/new-service/new-app300
Example: http://www.mysite.com/old-service/old-app4 ==> http://www.mysite.com/new-service/new-app400
Example: http://www.mysite.com/old-service/old-app5 ==> http://www.mysite.com/new-service/new-app500
Is it possible to create a class with the following parameter and pull it in from there:
"new-service/new-app100"
"new-service/new-app200"
"new-service/new-app300"
"new-service/new-app400"
"new-service/new-app500"
when HTTP_REQUEST {
set app_path [string tolower [getfield [HTTP::host] "." 0] ]
if { [matchclass $::newURI_apps contains $app_path] } {
HTTP::redirect "http://www.mysite.com/$app_path[HTTP::uri]"
}
}
Thanks all,
-DM
- hooleylistCirrostratusHi DM,
- DM_5174NimbostratusHi Aaron,
- DM_5174NimbostratusHi Aaron,
when HTTP_REQUEST { if { [HTTP::host] equals "www.mysite.com" } { log local0. "User went to http://[HTTP::host][HTTP::uri]" set site [HTTP::uri] switch -glob [string tolower [HTTP::uri]] { "/old-service/old-app1*" { HTTP::redirect "https://[HTTP::host]/new-service/new-app100" } "/old-service/old-app2*" { HTTP::redirect "https://[HTTP::host]/new-service/new-app200" } "/old-service/old-app3*" { HTTP::redirect "https://[HTTP::host]/new-service/new-app300" } "/old-service/old-app4*" { HTTP::redirect "https://[HTTP::host]/new-service/new-app400" } "/old-service/old-app5*" { HTTP::redirect "https://[HTTP::host]/new-service/new-app500" } } }
- The_BhattmanNimbostratusHi DM,
- DM_5174NimbostratusHi Bhattman,
- The_BhattmanNimbostratusYes you should be able to do this using datagroups. Here is a wiki shortcut that uses findclass command to use datagroups
- DM_5174NimbostratusHI Bhattman,
- The_BhattmanNimbostratusHi DM,
- hooleylistCirrostratusMore replies here:
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