270 Citrix NetScaler Policy Configuration and Reference Guide

bind patset pat1 .html

bind patset pat1 .php

bind patset pat1 .asp

bind patset pat1 .cgi

add rewrite action act1 insert_after 'HTTP.REQ.URL.PATH' '".html"'

add rewrite action act2 insert_after "HTTP.REQ.URL.PATH" '".php"'

add rewrite policy pol1 '!HTTP.REQ.URL.CONTAINS_ANY("pat1") && SYS.HTTP_CALLOUT(Call_html)' act1

add rewrite policy pol2 '!HTTP.REQ.URL.CONTAINS_ANY("pat1") && SYS.HTTP_CALLOUT(Call_php)' act2

bind rewrite global pol1 100 END

bind rewrite global pol2 101 END

Redirecting a Working URI to a New Format

Suppose that you have a set of working URLs that resemble the following:

/index.php?id=nnnn

To change these URLs to /nnnn and make sure that search engines update their indexes to the new URI format, you need to do the following:

Redirect the old URIs to the new ones so that search engines update their indexes.

Rewrite the new URI back to the old one so that the index.php script runs correctly.

To accomplish this, you can insert marker code into the query string (making sure that the marker code is not seen by visitors), and then removing the marker code for the index.php script.

The following examples redirect from an old link to a new format only if a marker is not present in the query string. The link that uses the new format is re-written back to the old format, and a marker is added to the query string.

Apache mod_rewrite solution

RewriteCond %{QUERY_STRING} !marker

RewriteCond %{QUERY_STRING} id=([-a-zA-Z0-9_+]+)

RewriteRule ^/?index\.php$ %1? [R,L]

RewriteRule ^/?([-a-zA-Z0-9_+]+)$ index.php?marker&id=$1 [L]

Page 284
Image 284
Citrix Systems 9.2 manual Redirecting a Working URI to a New Format, Apache modrewrite solution