264 Citrix NetScaler Policy Configuration and Reference Guide

add responder policy pol1 '!HTTP.REQ.HEADER("Name").EXISTS && !SYS.HTTP_CALLOUT(call)' act1

bind responder global pol1 100

NetScaler solution for redirection if a URL is wrong (method 2)

add HTTPCallout Call

set policy httpCallout Call -IPAddress 10.102.59.101 -port 80 -hostExpr '"10.102.59.101"' -returnType BOOL -ResultExpr 'HTTP.RES.BODY(100).CONTAINS("True")' -urlStemExpr '"/cgi-bin/ file_check.cgi"' -parameters query=http.req.url.path -headers Name("ddd")

add responder action act1 respondwith '"HTTP/1.1 302 Moved Temporarily\r\nLocation: http:// webserverB.com"+HTTP.REQ.URL+"\r\n\r\nHTTPCallout Used"' -bypassSafetyCheck yes

add responder policy pol1 '!HTTP.REQ.HEADER("Name").EXISTS && !SYS.HTTP_CALLOUT(call)' act1

bind responder global pol1 100

Rewriting a URL Based on Time

You can rewrite a URL based on the time. The following examples change a request for example.html to example.day.html or example.night.html, depending on the time of day.

Apache mod_rewrite solution for rewriting a URL based on the time

RewriteCond %{TIME_HOUR}%{TIME_MIN} >0700

RewriteCond %{TIME_HOUR}%{TIME_MIN} <1900

RewriteRule ^example\.html$ example.day.html [L]

RewriteRule ^example\.html$ example.night.html

NetScaler solution for rewriting a URL based on the time

add rewrite action act1 insert_before 'HTTP.REQ.URL.PATH.SUFFIX(\'.\',0)' '"day."'

add rewrite action act2 insert_before 'HTTP.REQ.URL.PATH.SUFFIX(\'.\',0)' '"night."'

add rewrite policy pol1 'SYS.TIME.WITHIN(LOCAL 07h 00m,LOCAL 18h 59m)' act1

add rewrite policy pol2 'true' act2

bind rewrite global pol1 101

bind rewrite global pol2 102

Page 278
Image 278
Citrix Systems 9.2 manual Rewriting a URL Based on Time, NetScaler solution for rewriting a URL based on the time