Forum Discussion

ukitsysadmin_95's avatar
ukitsysadmin_95
Icon for Nimbostratus rankNimbostratus
Feb 21, 2011

if 404 redirect else redirect

Hello all,

 

 

 

i'm trying to merge alot of our irules to tidy things up

 

 

 

Where am I going wrong with this irule

 

 

 

what i'm trying to do is the first part

 

 

 

forward any http::path using a data group (26,000 entries)

 

e.g.

 

if 404

 

from: /house/bedroom to /house/90/bedroom

 

 

 

The second part, i'm trying to do is

 

if 404

 

equals /search

 

forward to /search/results+http::query

 

 

 

hope this make sense

 

 

 

regards

 

 

 

James

 

 

 

when HTTP_REQUEST {

 

 

 

Save the path to a variable in case we see a 404 from the server

 

set path [HTTP::path]

 

set query [HTTP::query]

 

log local0. [HTTP::path]

 

}

 

 

 

when HTTP_RESPONSE {

 

if {[HTTP::status] == 404} {

 

 

 

set uri_token $path

 

 

 

if {$uri_token ne ""}{

 

set red_uri [findclass [string tolower $uri_token] ln3gv3_lower " "]

 

if {$red_uri ne ""}{

 

HTTP::redirect $red_uri

 

}

 

}

 

}

 

elseif {$query_token ne ""}{

 

set query_token [string range $query [expr {[string last ? $query] + 1}] end]

 

HTTP::redirect "[HTTP::host]/search/results?$query_token"

 

 

}

 

}

 

 

No RepliesBe the first to reply