Forum Discussion
DM_5174
Nimbostratus
Nov 09, 2007case-sensitive URL redirection - Code conversion
Hi all,
I have created the iRule below with the help of users on this forum in version 4.x, however we also have LBs with version 9.x. Please help me in converting this to version 9.x?
Basically when a someone connects using the URL "http://www.primarysite.com" they get routed to the main page, however, when they enter "home" after the FQDN, they need to get routed to "https://www.secondarysite.com/secure". The "home" needs to be case-insensitive, where it does not matter if they enter it in upper or lower case letters or even a combo, i.e. "hOmE", the result should be that they get routed to "https://www.secondarysite.com/secure/".
if (http_host == "www.primarysite.com" and http_uri matches_regex "/[hH][oO][mM][eE]")
{
redirect to "https://www.secondarysite.com/secure/"
}
else {
use pool APACHE_WEB_SERVERS
}
Thanks all!
- In 9.x iRules, string case is a lot easier to manage with the help of the TCL string command.
when HTTP_REQUEST { if { ([HTTP::host] equals "www.primarysite.com") && ([string tolower [HTTP::uri]] equals "/home") } { HTTP::redirect "https://www.secondarysite/secure/" } else { pool APACHE_WEB_SERVERS } }
when HTTP_REQUEST { if { ([HTTP::host] equals "www.primarysite.com") && ([string tolower [HTTP::uri]] equals "/home") } { HTTP::redirect "https://www.secondarysite/secure/" } }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects