Diacritics in iRules
I have URIs with accented characters for some international sites. I can forward a URI with diacritics by URL encoding the destination address.
But I don't seem to be able to match an encoded or decoded URL that originally contained accented characters in a switch statement, no matter what I try.
Forwarding to an encoded URL works:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
/testme {
HTTP::respond 301 Location "http://mydomain.com/restauraci%C3%B3n"
}
}
Matching an encoded URI in a switch statement doesn't:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
/restauraci%C3%B3n {
HTTP::respond 301 Location "http://mydomain.com/newlocation"
}
}
Browsing to http://mydomain.com/restauración (http://mydomain.com/restauraci%C3%B3n) doesn't get forwarded.
I did a test to see what the decoded URI looks like:
when HTTP_REQUEST {
switch [URI::decode [string tolower [HTTP::uri]]] {
/restauraci* {
200 content "[URI::decode [HTTP::uri]]"
}
}
Browsing to http://mydomain.com/restauración I get "/restauración"
Using the same rule without the decode, I get "/restauraci%C3%B3n"
Trying to match the decoded URI (or anything else) doesn't work either:
when HTTP_REQUEST {
switch [URI::decode [string tolower [HTTP::uri]]] {
/restauración -
/restauraci%C3%B3n -
/restauración {
HTTP::respond 301 Location "http://mydomain.com/newlocation"
}
}
Is there a simple way to filter on an encoded URI?