Forum Discussion
TMM utilization increaseing after iRule change
I don't know how to post it as a code here in this forum.
I just paste the rule code into notepad and then into here.
here is the rule:
when HTTP_REQUEST {
don't run the rule if it's a mobile redirect
if {[info exists mobile_match] && $mobile_match==1} {
log local0. "It's a mobile client: [IP::client_addr]"
} else {
log local0. "normal client: [IP::client_addr]"
set rule_active 1
set default_category 1
set uri_orig [string tolower [HTTP::uri]]
set uri_prefix_category "/default/defaultcatg.asp?rewrite=1&catg="
set uri_prefix_listing "/default/defaultlist.asp?rewrite=1&catg="
set uri_prefix_carsandbikes_listing "/carsandbikes/defaultlist.aspx?rewrite=1&categorynr="
Required params
set para_c [findstr $uri_orig "/c/" ]
set para_l [findstr $uri_orig "/l/" ]
set para_b [findstr $uri_orig "/b/" ]
if { $para_c ne "" } {
set parameters [findstr $para_c "/c/" 2]
log local0. "Parameter para_c: $para_c $parameters"
} elseif { $para_l ne "" } {
set parameters [findstr $para_l "/l/" 2]
log local0. "Parameter para_l: $para_l $parameters"
} elseif { $para_b ne "" } {
set parameters [findstr $para_b "/b/" 2]
log local0. "Parameter para_b: $para_b $parameters"
} else {
set parameters ""
}
log local0. "Parameters: $parameters"
Optional params
set para_cn [findstr $parameters "/cn" 3 "/"]
set para_an [findstr $parameters "/an" 3 "/"]
set para_ln [findstr $parameters "/ln" 3 "/"]
set para_ls [findstr $parameters "/ls" 3 "/"]
set para_lt [findstr $parameters "/lt" 3 "/"]
set para_pn [findstr $parameters "/pn" 3 "/"]
set para_ps [findstr $parameters "/ps" 3 "/"]
set para_xml [findstr $parameters "/xml" 4 "/"]
log local0. "Parameter para_an: $para_an"
switch -exact $uri_orig {
"/kaufen" -
"/acheter" -
"/kobe" -
"/kjope" -
"/pris" -
"/angebote" -
"/buy" {
HTTP::respond 301 Location http://[HTTP::host][HTTP::uri]/
}
}
switch -glob $uri_orig {
"/kaufen/*" -
"/acheter/*" -
"/kobe/*" -
"/kjope/*" -
"/pris/*" -
"/angebote/*" -
"/buy/*" {
Process required parameters
Set the correct categorynumber
if { $para_cn equals "" } {
set para_cn $default_category
} else {
do nothing
}
Set the article number
if { $para_an != "" } {
Add auctionnr to the URI
set para_an "&auctionnr=$para_an"
}
Workaround for "v" and "w" else Default new_uri
if { "$uri_orig" contains "/v/" or "$uri_orig" contains "/w/" } {
set rule_active 0
log local0. "rule_active: none"
} else {
set uri_new $uri_prefix_category$para_cn
}
Process URI prefix
Create URI prefix for listing page
if { $para_l != "" } {
set uri_new $uri_prefix_listing$para_cn
} elseif { $para_b != "" } {
set uri_new $uri_prefix_carsandbikes_listing$para_cn
} else {
set uri_new $uri_prefix_category$para_cn
}
Process optional parameters
if { $para_ln != "" } {
Add langeuagenr to the URI
set uri_new "$uri_new&languagenr=$para_ln"
}
if { $para_ls != "" } {
Add listingsort to the URI
set uri_new "$uri_new&listingsort=$para_ls"
}
if { $para_lt != "" } {
Add listingtype to the URI
set uri_new "$uri_new&listingtype=$para_lt"
}
if { $para_pn != "" } {
Add pagenumber to the URI
set uri_new "$uri_new&pagenr=$para_pn"
}
if { $para_ps != "" } {
Add pagesize to the URI
set uri_new "$uri_new&pagesize=$para_ps"
}
if { $para_xml != "" } {
Add xml to the URI
set uri_new "$uri_new&xml=$para_xml"
}
Set new URL
log local0. "[HTTP::host] $uri_orig $uri_new"
if { $rule_active ne 0 } {
if {[catch { HTTP::header insert "X-REWRITTENURL [HTTP::uri]" } result]} {
log local0. "[HTTP::host] [IP::client_addr]:[TCP::local_port] Error on Header Insert X-REWRITTENURL"
}
if { [HTTP::uri] equals $uri_new } {
log local0. "[HTTP::uri] URLs equal!"
}
HTTP::uri $uri_new
log local0. "[HTTP::host] [HTTP::uri] -> $uri_new"
}
}
}
}
}
Thanx for help
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