redirect for uppercase URI

Hello, I have a issue with a redirect, part of the URI is uppercase /something/somethingelse/NEW/index.html, and I’d like to redirect to lower /something/somethingelse/new/index.html

Now, if I do string tolower [HTTP::uri] ends_with “/new/” it works, but if I try /something/somethingelse/NEW/index.html it wouldn’t redirect because the rule matches only /new/

How can I work this around ?

Thank you

Hi,

You can use the following irule to redirect to lower case :

when HTTP_REQUEST {
    if {  [string tolower [HTTP::path]] contains "/new/" } {
        HTTP::redirect [string tolower [HTTP::uri]]
    }
}

It won’t work, the page won’t load and I get “The page isn’t redirecting properly” error. I’m using “ends_with” because nothing else work (except “start_with”, but that doesn’t help me either)

Hi,

just few examples :

by using ends_with "/new/ "

-> /test/new/ - ok

-> /test/new/index.html - nok

By using contains “/new/” :

-> /test/new/ - ok

-> /test/new/index.html - ok

Hi,

just few examples :

by using ends_with "/new/ "

-> /test/new/ - ok

-> /test/new/index.html - nok

By using contains “/new/” :

-> /test/new/ - ok

-> /test/new/index.html - ok

You may hit a loop with my irule. You need to be more specific on the if condition

“contains” isn’t working I get “The page isn’t redirecting properly” error

“contains” isn’t working I get “The page isn’t redirecting properly” error

Hi,

can you try this one, the redirect issue should be fixed :

when HTTP_REQUEST {
    if {  [string tolower [HTTP::path]] contains "/new/" and [URI::query redirect] eq "" } {
        if { [HTTP::uri] contains "?" } {
            HTTP::redirect [string tolower [HTTP::uri]]"&redirect=1"
        } else {
            HTTP::redirect [string tolower [HTTP::uri]]"?redirect=1"
        }
    }
}

If you know which part of the uri is uppercase, you can change the if condition like below :

when HTTP_REQUEST {
    if {  [HTTP::path] contains "/NEW/"} {
        HTTP::redirect [string tolower [HTTP::uri]]
    }
}

If you know which part of the uri is uppercase, you can change the if condition like below :

when HTTP_REQUEST {
    if {  [HTTP::path] contains "/NEW/"} {
        HTTP::redirect [string tolower [HTTP::uri]]
    }
}

That worked, Thank you.

That worked, Thank you.

Thanks Yann Desmarest. Thats worked for me as well. The option to vote for your answer seems to be disabled for some reason. Anyway, Thanks Heaps!

Thanks Yann Desmarest. Thats worked for me as well. The option to vote for your answer seems to be disabled for some reason. Anyway, Thanks Heaps!