Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

String map and redirect

I need to perform a redirect that changes a URI from this format:

mysite.com/it/folder/files/FILESANDFILES

to:

mysite.com/it/folder/files/filesANDfiles

In other words, part of the URI needs to be converted to lowercase, while leaving an intermediate portion intact.  Since the portion that needs to be converted to lowercase is very specific, I tried using a string map as follows:

when HTTP_REQUEST {
if { [string tolower [HTTP::path]] starts_with "/it/folder/files" }
{
HTTP::redirect [string map {"folder=FILESANDFILES" "folder=filesANDfiles"} [HTTP::path]]
}
}

This doesn't work, even though it's very similar to other iRules I've used that do work.  Any thoughts? 

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
I found the problem, an infinite loop is created by this iRule since the iRule is not case sensitive enough.  Removing "tolower" does not solve the problem.  I don't have a solution though. 
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Solved:

when HTTP_REQUEST { if { [string tolower [HTTP::path]] starts_with "/it/folder/files" and [HTTP::uri] contains "folder=FILESANDFILES"} { HTTP::redirect [string map {"folder=FILESANDFILES" "folder=filesANDfiles"} [HTTP::uri]] } }
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER
Nice work. You could make it a little more precise if you looked for the folder parameter name and value in just the query as opposed to the full URI:


when HTTP_REQUEST {
   if { [string tolower [HTTP::path]] starts_with "/it/folder/files" and [HTTP::query] contains "folder=FILESANDFILES"} { 
      HTTP::redirect [string map {"folder=FILESANDFILES" "folder=filesANDfiles"} [HTTP::uri]]
   }
}


Aaron
0