Forum Discussion

ERLomboy_27803's avatar
ERLomboy_27803
Icon for Nimbostratus rankNimbostratus
Aug 08, 2013

Merging iRules to fix a multiple redirect error

Hi Guys,

 

Need your help with an issue I'm having on a redirect request of a company website we've acquired to ours.

 

This is the rule i'm trying to add. Note: I'm only a beginner.

 

when HTTP_REQUEST {

 

if { [HTTP::host] ends_with "acquired-site" } {

 

HTTP::redirect “https://www.ourmainsite.com/yadi/yada.aspx” }

 

else {

 

HTTP::redirect "https://www.ourmainsite.com[HTTP::uri]"

 

}

 

}

 

 

Now below is the one we're utilizing in our main site.

 

when HTTP_REQUEST priority 250 {

 

if { [string tolower [HTTP::uri]] ne "/powerrangers" } {

 

switch -exact [string tolower [HTTP::host]] {

 

"www.ourmainsite.com" {

 

if {[TCP::local_port] == 80} {

 

HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"

 

}

 

elseif { [string tolower [HTTP::uri]] starts_with "/nukem3d/" } {

 

if { [string tolower [HTTP::host]] ne "forums.ourmainsite.com" } {

 

HTTP::respond 301 Location "https://forums.ourmainsite.com[HTTP::uri]"

 

}

 

} elseif {[string tolower [HTTP::uri]] starts_with "/summergames/" || [string tolower [HTTP::uri]] starts_with "/summergames"} {

 

HTTP::respond 301 Location "http://summergames.ourmainsite.com"

 

}

 

 

 

 

}

 

"ourmainsite.com" {

 

if { [matchclass $::wwwredirects equals [string tolower [HTTP::path]]] } {

 

HTTP::respond 301 Location "https://www.ourmainsite.com[HTTP::uri]"

 

} elseif { [TCP::local_port] == 80 } {

 

HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"

 

} elseif { [string tolower [HTTP::uri]] starts_with "/dotaplay/maps/121/" || [string tolower [HTTP::uri]] starts_with "/dotaplay/maps/102/" } {

 

HTTP::respond 301 Location "https://www.ourmainsite.com[HTTP::uri]"

 

} elseif { [string tolower [HTTP::uri]] starts_with "/supermariobros/" } {

 

if { [string tolower [HTTP::host]] ne "forums.ourmainsite.com" } {

 

HTTP::respond 301 Location "https://forums.ourmainsite.com[HTTP::uri]"

 

}

 

} elseif {[string tolower [HTTP::uri]] starts_with "/summergames/" || [string tolower [HTTP::uri]] starts_with "/summergames"} {

 

HTTP::respond 301 Location "http://summergames.ourmainsite.com"

 

}

 

 

 

}

 

} else {

 

HTTP::redirect http://powerpuff.ourmainsitecom

 

}

 

}

 

 

 

12 Replies