Forum Discussion
Help reviewing an iRule
Hi,
Can someone help me out customize an existing iRule?
when HTTP_REQUEST {
if { [string tolower [HTTP::uri]] ne "/superbook" } {
switch -exact -- [string tolower [HTTP::host]] {
"www.discoverypage.com" {
if {[TCP::local_port] == 80} {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
}
elseif { [string tolower [HTTP::uri]] starts_with "/gospels/" } {
if { [string tolower [HTTP::host]] ne "gospels.discoverypage.com" } {
HTTP::respond 301 Location "https://gospels.discoverypage.com[HTTP::uri]"
}
}
}
"discoverypage.com" {
if { [matchclass $::wwwredirects equals [string tolower [HTTP::path]]] } {
HTTP::respond 301 Location "https://www.discoverypage.com[HTTP::uri]"
} elseif { [TCP::local_port] == 80 } {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
} elseif { [string tolower [HTTP::uri]] starts_with "/dotnet/excel/114/" || [string tolower [HTTP::uri]] starts_with "/dotnet/excel/102/" } {
HTTP::respond 301 Location "https://www.discoverypage.com[HTTP::uri]"
}
elseif { [string tolower [HTTP::uri]] starts_with "/forumsdotnet/" } {
if { [string tolower [HTTP::host]] ne "forums.discoverypage.com" } {
HTTP::respond 301 Location "https://forums.discoverypage.com[HTTP::uri]"
}
}
}
default {
if { [TCP::local_port] == 80 } {
HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"
}
}
}
} else {
HTTP::redirect http://superbook.discoverypage.com
}
}
We have a site (superbook.discoverypage.com) that will be shutdown but the market team wants the site still get redirected to our main site (www.discoverypage.com). When I type the cname to a browser, it adds its name as a prefix to the main site.
Please help modify the iRule above so when users try to hit superbook.discoverypage.com, it will get redirected to www.discoverpage.com.
I'm not sure what to do as well with the else statement since the site superbook.discoverypage.com will eventually get shut down. Please advise on this as well.
PS: I replaced the sites with dummy ones. 🙂
Thanks!!!
2 Replies
- Arie
Altostratus
- Do you need to retain the path in the redirect?
- Which version LTM are you on? Judging by the "matchclass" statement it's not a current version.
By the way, is "discoverypage.com" your actual domain? If so you may want to check your registration as it currently goes to a HugeDomains DNS hijack page.
- Arie
Altostratus
This should work if both sites are using the same VIP. If they're not using the same VIP you'll want to move the redirect from superbook.discoverypage.com to www.discoverypage.com to its own iRule and assign that to the VIP for superbook.
when HTTP_REQUEST { if { [HTTP::host] equals "superbook.discoverypage.com" } { HTTP::respond 301 Location "http://www.discoverypage.com/" } else { switch -exact -- [string tolower [HTTP::host]] { "www.discoverypage.com" { if {[TCP::local_port] == 80} { HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]" } elseif { [string tolower [HTTP::uri]] starts_with "/gospels/" } { if { [string tolower [HTTP::host]] ne "gospels.discoverypage.com" } { HTTP::respond 301 Location "https://gospels.discoverypage.com[HTTP::uri]" } } } "discoverypage.com" { if { [matchclass $::wwwredirects equals [string tolower [HTTP::path]]] } { HTTP::respond 301 Location "https://www.discoverypage.com[HTTP::uri]" } elseif { [TCP::local_port] == 80 } { HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]" } elseif { [string tolower [HTTP::uri]] starts_with "/dotnet/excel/114/" || [string tolower [HTTP::uri]] starts_with "/dotnet/excel/102/" } { HTTP::respond 301 Location "https://www.discoverypage.com[HTTP::uri]" } elseif { [string tolower [HTTP::uri]] starts_with "/forumsdotnet/" } { if { [string tolower [HTTP::host]] ne "forums.discoverypage.com" } { HTTP::respond 301 Location "https://forums.discoverypage.com[HTTP::uri]" } } } default { if { [TCP::local_port] == 80 } { HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]" } } } removed redirect to superbook.discoverypage.com }
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