Forum Discussion
jbergeron_10592
Nimbostratus
Jan 24, 2008Unable to make this work - Help Please
Good Morning -
Where am I going wrong? After struggling through this for the past 3 days, I am at my wits end. We are trying to convert our 4.5 rules to 9.4 and to this point have been completely unsuccessful. If anyone out there could help me, it would be much appreciated!
Here are the two rules I am trying to convert (and my feable attempts as well):
XYZ Redirect -
if (not (http_host == "www.xyz.com")) {
if (http_host == "mobile.xyz.com") {
redirect to "http://www.xyz.com/mobile"
}
else {
if (http_uri matches_regex "xyzfreeconversion.asp" or http_uri matches_regex "getconversion.asp" or http_uri matches_regex "whoami.asp") {
use pool LAX_ORIGIN_SERVERS
}
else {
redirect to "http://www.xyz.com/%u"
}
}
}
else {
use pool LAX_ORIGIN_SERVERS
}
My attempt -
when HTTP_REQUEST {
if {not [HTTP::host] == "www.xyz.com" } {
if { [HTTP::host] == "mobile.xyz.com" } {
HTTP::redirect "http://www.xyz.com/mobile"
}
else {
if { [http_uri] matches_regex "xyzfreeconversion.asp" or [http_uri] matches_regex "getconversion.asp" or [http_uri] matches_regex "whoami.asp" } {
pool LAX_ORIGIN_SERVERS
}
else {
HTTP::redirect "http://www.xyz.com/%u"
}
}
}
else {
pool LAX_ORIGIN_SERVERS
}
}
Second Rule -
if (not (http_host == "www.xyzfree.net")) {
if (http_host == "www.xyzfree.com" or http_host == "www.freexyz.com" or http_host == "www.freexyz.net") {
redirect to "http://www.xyz.com/"
}
else {
redirect to "http://www.xyzfree.net/%u"
}
}
else {
use pool xyzFree
}
My attempt -
when HTTP_REQUEST {
if {not [HTTP::host] == "www.xyzfree.net" } {
if { [HTTP::host] == "www.xyzfree.com" or [HTTP::host] == "www.freexyz.com" or [HTTP::host] == "www.freexyz.net" } {
HTTP::redirect "http://www.xyz.com/"
}
else {
HTTP::redirect "http://www.xyzfree.net/%u"
}
}
else {
pool xyzFree
}
if {not [HTTP::host] == "www.xyz.com" } {
}
}
Thanks in advance for your assistance!
JB
- JRahm
Admin
I'm not sure I have all your if/else logic right, so check it. Also, I substituted contains for matches_regex to save resources, but this may not meet your needs.when HTTP_REQUEST { if {not ([HTTP::host] eq "www.xyz.com") } { if { [HTTP::host] eq "mobile.xyz.com" } { HTTP::redirect "http://www.xyz.com/mobile" } elseif { ([HTTP::uri] contains "xyzfreeconversion.asp") \ or ([HTTP::uri] contains "getconversion.asp") \ or ([HTTP::uri] contains "whoami.asp") } { pool LAX_ORIGIN_SERVERS } else { HTTP::redirect http://www.xyz.com/[HTTP::uri] } } else { pool LAX_ORIGIN_SERVERS } }
- jbergeron_10592
Nimbostratus
Thanks for the quick reply... I will give it a shot and reply back with results! - jbergeron_10592
Nimbostratus
The first one works...but the one I tried naturally didn't...I have somewhat of an inverse Midas touch these days... - JRahm
Admin
I think this is what you're after in the same context as your v4 rule:when HTTP_REQUEST { if { not ([HTTP::host] eq "www.xyzfree.net") } { if { ([HTTP::host] eq "www.xyzfree.com") \ or ([HTTP::host] eq "www.freexyz.com") \ or ([HTTP::host] eq "www.freexyz.net") } { HTTP::redirect http://www.xyz.com } else { HTTP::redirect http://www.xyzfree.net/[HTTP::uri] } } else { pool xyzFree } }
when HTTP_REQUEST { if { [HTTP::host] eq "www.xyzfree.net" } { pool xyzFree } elseif { ([HTTP::host] eq "www.xyzfree.com") \ or ([HTTP::host] eq "www.freexyz.com") \ or ([HTTP::host] eq "www.freexyz.net") } { HTTP::redirect http://www.xyz.com } else { HTTP::redirect http://www.xyzfree.net/[HTTP::uri] } }
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