Forum Discussion
irule to redirect url
at the moment we have this irule
elseif { ([string tolower [HTTP::uri]] starts_with "/test") } { HTTP::redirect "http://m.domain.com[HTTP::uri]"
So what it does is this: if a user goes here www.domain.com/test/sport/competitions/champions-league/Madrid-2403444.html?utm_source=exacttarget&utm_medium=email&utm_campaign=pc01tmn2&utm_content=g01&sb_cid=3516 user will be redirected to https://m.domain.com/test/sport/uefa-competitions/uefa-champions-league/Roma-v-Real-Madrid-2403444.html
but we want to redirect to https://m.domain.com/test/sport/competitions/champions-league/Madrid-2403444.html?utm_source=exacttarget&utm_medium=email&utm_campaign=pc01tmn2&utm_content=g01&sb_cid=3516
instead , how do we achieve this using irule?
- Andy_McGrath
Cumulonimbus
If your www.domain.com and m.domain.com hit the same Virtual Server you will always trigger this iRule as the 'uri' after the redirect will still start with '/test' and create a redirect loop on the client. Try the following simplified iRule:
when HTTP_REQUEST { if{([string tolower {HTTP::host] eq "www.domain.com") && ([string tolower [HTTP::uri]] starts_with "/test")}{ HTTP::redirect "http://m.domain.com[HTTP::uri]" } }
Also is looks to only be part of the iRule, can you post the full iRule so get a better view of what is happening?
- raduioncu_16351
Nimbostratus
At first glance this should redirect correctly! [HTTP::uri] contains both [HTTP::path] and [HTTP::query] (the latter one which you seem to be missing in the redirect example). What is before the "elseif" and does the mobile server issue any redirects of it's own? Test with 'curl -IvkL '.
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