Appendix E

Migration of Apache mod_rewrite Rules to Advanced Policies

269

The first two of the following examples show adding an extension to all request URLs. In the last example, one of two file extensions is added. Note that in the last example, the mod_rewrite module can easily find the file extension because this module resides on the Web server. In contrast, the NetScaler must invoke an HTTP callout to check the extension of the requested file on the Web server.

Based on the callout response, the NetScaler adds the .html or .php extension to the request URL.

Note: In the second NetScaler example, an HTTP callout is used to query a script named file_check.cgi hosted on the server. This script checks whether the argument that is provided in the callout is a valid file name.

Apache mod_rewrite solution for adding a .php extension to all requests

RewriteRule ^/?([a-z]+)$ $1.php [L]

NetScaler policy for adding a .php extension to all requests

add rewrite action act1 insert_after 'HTTP.REQ.URL' '".php"'

add rewrite policy pol1 'HTTP.REQ.URL.PATH.REGEX_MATCH(re#^/ ([a-z]+)$#)' act1

bind rewrite global pol1 100

Apache mod_rewrite solution for adding either .html or .php extensions to requests

RewriteCond %{REQUEST_FILENAME}.php -f

RewriteRule ^/?([a-zA-Z0-9]+)$ $1.php [L]

RewriteCond %{REQUEST_FILENAME}.html –f

RewriteRule ^/?([a-zA-Z0-9]+)$ $1.html [L]

NetScaler policy for adding either .html or .php extensions to requests

add HTTPCallout Call_html

add HTTPCallout Call_php

set policy httpCallout Call_html -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+".html"

set policy httpCallout Call_php -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+".php"

add patset pat1

Page 283
Image 283
Citrix Systems 9.2 manual 269, NetScaler policy for adding a .php extension to all requests