Forum Discussion
iRule to redirect for specific uri
We want if customer request https://abc.com/login then it gets redirected to https://abc.com/login?local=true
I wrote below iRule
when HTTP_REQUEST {
set lowerCaseHost [ string tolower [HTTP::host] ]
set lowerCaseUri [string tolower [HTTP::uri]]
if { $lowerCaseUri equals "/login" } {
HTTP::redirect "https://abc.com/login?local=true"
return
}
}
it is working... But when customer types only https://abc.com then also it gets redirected to https://abc.com/login?local=true we want redirection should happen only for https://abc.com/login Not sure whats wrong with this iRule. Please suggest.
1 Reply
Hi
you may try the snippet belowe to differentiate between the different host names...
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] equals "/login" } then { if { [string tolower [HTTP::host]] equals "abc.de" } then { HTTP::redirect "https://abc.com/login?local=true" return } else { HTTP::redirect "https://www.abc.com/login?local=true" return } } }Note: I've removed the $lowerCaseHost and $lowerCaseUri variables because of performance reasons. Well, it make sense to use those variables, but just if you need the value more than once... 😉
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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