Forum Discussion
DM_5174
Nov 07, 2007Nimbostratus
Case-sensitive URL Redirection
Hello all,
I have created a 4x iRule that will redirect based on specific
words after the FQDN "http://%h/". So if i put "http://www.primarysite.com",
i get redirected to the main page, however if you enter "home" or "HOME" (lower case or upper case), it redirects you to the secondary site.
The quesion here is: Can I use RegEX, for example /[H][h][O][o][M][m][E][e]
in the code so to consolidate so i don't have to use two "if" statements?
By doing this, the user can put any of the combo upper or lower and still
get the same result, which is a redirection to "http://www.secondarysite.com/secure".
if (http_host == "www.primarysite.com" and http_uri == "/home") {
redirect to "www.secondarysite.com/secure/"
}
else {
if (http_host == "www.primarysite.com" and http_uri == "/HOME") {
redirect to "www.secondarysite.com/secure/"
}
else {
use pool APACHE_WEB_SERVERS
}
}
Thank you!
- hooleylistCirrostratusHello,
- DM_5174NimbostratusI have tried the "i" switch and it does not work for the irule version i am running. I have tried the other approach and came up with a 404 error. I think the syntax is incorrect...Can you let me know if this is correct?
if (http_host == "www.primarysite.com" and http_uri == "/[hH][oO][mM][eE]") { redirect to "www.secondarysite.com/secure/" } else { use pool APACHE_WEB_SERVERS }
- hooleylistCirrostratusI assume you're getting a 404 because the request is for /home and that doesn't exist on the web servers in the apache pool.
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 }
- DM_5174NimbostratusAwesome! that worked!
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