Create short links for commercials

Wonderkitchen wants to promote it’s most colourful content. It’s located at it is currently located in Unfortunately, marketing doubts, users won’t be able to remember /Commercials/current_commercial.html. They want to have an easier URL: /cookbook. Not case-sensitive, of course! There will be more commercials like this in the near future.

The solution

The solution is a simple string-map. Its structure will be the shortened URL as a key and the original URL as a value.


Key Value
/cookbook /Commercials/current_commercial.html
/red /red.htm

The structure will be easy, so even the marketing department will be able to to the changes needed (given, you let them touch your ADC).

It’s always a good style to keep the number of policies low by using string-maps, pattern-sets or similar lists. It’s by far less overhead, both, from the perspective of CPU and memory.

The string Map

Navigate to App ExpertStringmaps. Click Add.

NetScaler: Stringmap to simplify URLs

We added keys for this commercial and all colours.

The policy

We can do two things: A responder policy (it is not transparent to users) or a rewrite (transparent to users). It’s a matter of taste.

  • In case of a rewrite, the policy is of type replace. We want to replace the HTTP.REQ.URL, so the requested URL.
  • In case of a responder it’s of type redirect.

I don’t add the rewrite policy here, you may follow the guide for my very user-confusing policy here.

The action

App ExpertResponderActions click Add.

NetScaler: Policy action to simplify URLs

This action makes the URL case-insensitive (SET_TEXT_MODE(IGNORECASE)) and then looks up the URL in the string-map and redirects to the corresponding value.

The Response Status Code may either be 302 or 301. From the perspective of a user, there is no difference. However, search engines make a big difference: While they might not follow a 302, as it is a temporary redirect and expected to be removed soon, they are expected to follow a 301, as this is new data to put into their index.

There might be a Reason Phrase. This is a text telling the user-agent, why it gets redirected. But the user-agent, usually the browser, does neither look at your reason phrase nor would be interested in your reason, we usually leave this blank.

The policy

NetScaler: Policy to simplify URLs

The policy expression, similar to the action, has to get case-insensitive. The expression simply looks up the key in a string-map (IS_STRINGMAP_KEY: any string-map key is OK).

Binding this policy

The policy – like any other policy – has to get bound to our colour server to make it work. We unbound all other responder policies and bound it using a priority of 100.

NetScaler: Binding a policy to simplify URLs


try to connect to all of these shortened URLs. They should get replaced with the long URL.

Try different spellings: /CookBook, /cookbook, /cOOKbOOK. All should return the same beautiful page!

If it does not work: Check the string-map. Does it contain a leading /? The URL must not have a trailing /). Is the policy bound correctly? Does it get hit?

Leave a Comment

Your email address will not be published. Required fields are marked *