260 Citrix NetScaler Policy Configuration and Reference Guide

Converting URL Variations into Canonical URLs

On some Web servers you can have multiple URLs for a resource. Although the canonical URLs should be used and distributed, other URLs can exist as shortcuts or internal URLs. You can make sure that users see the canonical URL regardless of the URL used to make an initial request.

In the following examples, the URL /~user is converted to /u/user.

Apache mod_rewrite solution for converting a URL

RewriteRule ^/~([^/]+)/?(.*) /u/$1/$2[R]

NetScaler solution for converting a URL

add responder action act1 redirect '"/u/"+HTTP.REQ.URL.AFTER_STR("/ ~")' -bypassSafetyCheck yes

add responder policy pol1 'HTTP.REQ.URL.STARTSWITH("/~") && HTTP.REQ.URL.LENGTH.GT(2)' act1

bind responder global pol1 100

Converting Host Name Variations to Canonical Host Names

You can enforce the use of a particular host name for reaching a site. For example, you can enforce the use of www.example.com instead of example.com.

Apache mod_rewrite solution for enforcing a particular host name for sites running on a port other than 80

RewriteCond %{HTTP_HOST}

!^www.example.com

RewriteCond %{HTTP_HOST}

!^$

RewriteCond %{SERVER_PORT}

!^80$

RewriteRule ^/(.*)

http://www.example.com:%{SERVER_PORT}/$1

[L,R]

 

Apache mod_rewrite solution for enforcing a particular host name for sites running on port 80

RewriteCond %{HTTP_HOST}

!^www.example.com

RewriteCond

%{HTTP_HOST}

!^$

RewriteRule

^/(.*)

http://www.example.com/$1 [L,R]

Page 274
Image 274
Citrix Systems 9.2 Converting URL Variations into Canonical URLs, Converting Host Name Variations to Canonical Host Names