Forum Discussion
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
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]] } }
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]] } }
- demmo_251289Nimbostratus
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)
- You may hit a loop with my irule. You need to be more specific on the if condition
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
- demmo_251289Nimbostratus"contains" isn't working I get "The page isn't redirecting properly" error
- Yann_Desmarest_Nacreous
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
- demmo_251289Nimbostratus"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" } } }
- Yann_Desmarest_Nacreous
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]] } }
- demmo_251289NimbostratusThat worked, Thank you.
- raj_paras_16233Nimbostratus
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!
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]] } }
- demmo_251289NimbostratusThat worked, Thank you.
- raj_paras_16233Nimbostratus
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!
Recent Discussions
Related Content
* 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