Forum Discussion
meena_60183
Nimbostratus
Aug 02, 2010URI manipulation and redirect
I had a request a few months ago to do some URI manipulation for redirect. A sample URL would be
https://www.host.com/506/dept_name/ops/Performance%20Improvement%20Team%20Meerting%20Minutes/2_24_10%20PC.doc
would be redirected to
https://dept_name.host.com/ops/Performance%20Improvement%20Team%20Meerting%20Minutes/2_24_10%20PC.doc
and at that time, I was able to take care of it with the following irule.
when HTTP_REQUEST {
set uri [HTTP::uri]
if { ( $uri starts_with "/506/dept_name" ) } {
remove the first 15 chars (/506/dept_name) from the URI
HTTP::redirect "https://dept_name.host.com[string range $uri 16 end]"
}
}
Now I have a similar request for the same website but the string length for dept_name is different. I thought instead of doing this for each department, I will just remove the first 2 directories from the URI list and keep the rest and do a redirect. I am able to parse the URI to get the folder names but I have trouble building back the URI list without the first 2 folders. I used the following to parse the URI
set depth [URI::path [HTTP::uri] depth]
for {set i 1} {$i <= $depth} {incr i} {
set dir [URI::path [HTTP::uri] $i $i]
log local0. "dir\[$i\]: $dir"
}
log local0. "Basename: [URI::basename [HTTP::uri]]"
I need some hints on how I can save the partial URI to do the redirect.
- hoolio
Cirrostratus
Maybe something like this?
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