Structured Homedirs

The Citrix NetScaler can be placed in front of a webserver farm that is running Apache. The same re-write rules that run on Apache, can be implemented on the Citrix NetScaler.

Some sites with thousands of users usually use a structured homedir layout, i.e. each homedir is in a subdirectory which begins for instance with the first character of the username. So, /~foo/anypath is /home/f/foo/.www/anypath while /~bar/anypath is /home/b/bar/.www/anypath.Following rules could be used to implement this.

Apache rewrite:

RewriteRule   ^/~(([a-z])[a-z0-9]+)(.*)  /home/$2/$1/.www$3

AppExpert rewrite:

Add rewrite action act1 replace 'HTTP.REQ.URL'  '<span class="code-quote">"/home/"</span>+ HTTP.REQ.URL.AFTER_STR(<span class="code-quote">"~"</span>).PREFIX(1)+<span class="code-quote">"/"</span>+ HTTP.REQ.URL.AFTER_STR(<span class="code-quote">"~"</span>).BEFORE_STR(<span class="code-quote">"/"</span>)+<span class="code-quote">"/.www"</span>+HTTP.REQ.URL.SKIP(\'/\',1)'  -bypassSafetyCheck yes

Add rewrite policy pol1  'HTTP.REQ.URL.PATH.STARTSWITH(<span class="code-quote">"/~"</span>)' act1

Bind rewrite global pol1 100

Tap into the power of AppExpert!