Old to New Internal URL Rewrite



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.

Assume you have recently renamed the page foo.html to bar.html and now want to provide the old URL for backward compatibility. Actually you want users of the old URL to not recognize that the pages were renamed.

Example : Rewrite the old URL to the new one internally via the following rule, let the base directory be /~quux/.

Apache rewrite:

RewriteEngine  on
RewriteBase    /~quux/
RewriteRule    ^foo\.html$  bar.html



AppExpert rewrite: (There are two ways to do this)

“Solution 1”
add rewrite action act1 replace 'HTTP.REQ.URL.AFTER_STR(<span class="code-quote">"/~quux"</span>).SUBSTR(<span class="code-quote">"foo.html"</span>)' '<span class="code-quote">"bar.html"</span>'

add rewrite policy pol1 'HTTP.REQ.URL.ENDSWITH(<span class="code-quote">"/~quux/foo.html"</span>)' act1

bind rewrite global pol1 100
“Solution 2”
Add rewrite action act1 replace 'HTTP.REQ.URL.PATH.SUFFIX(\'/\',0)' '<span class="code-quote">"bar.html"</span>'

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

Bind rewrite global pol1 100



Tap into the power of AppExpert!