Advanced Virtual Hosting

Cherokee currently support a mechanism by which a single virtual server can handle many different domains. The document root of this virtual server is built dynamically, so even if the domains share a common configuration they can use a number of different Document Root directories.


The following replacement variables are supported. Let’s suppose a request to the domain for the examples:

Variable Example Description


Full domain name



Top Level Domain



Domain without the TLD


Root domain



First sub-domain



Second sub-domain


The template subsystem is sophisticated enough to provide slicing support, with a grammar that is heavily inspired in the Python syntax. It supports positive and negative indexes, and the omission of one of the index numbers.

This basically allows to define partial replacements for any of the supported variables, meaning that a portion of the replacement string can be used instead of the whole string.

If you are not familiar with the Python syntax, these are the rules:

  1. For any given string, a slice is denoted as string[x:y]

  2. Indices start at 0, and [x:y] denotes a range comprehending from index x (included) to index y (excluded).

  3. If negative indices are used, the count starts backwards from the last element, meaning -1 will be the last, -2 will be the previous one and so on.

It is pretty straight forward. Here are some examples:

Variable Explanation


From the beginning of the string until the character at index 1 (not included)


From index 1 (included), to index 2 (not included)


From the beginning of the string until the last character (not included). Since 0 is the first character, counting backwards one element would be the last element of the string.

As a practical usage example, we will suppose a scenario where thousands of virtual servers are distributed within a two-level directory tree in order to speed things up. Something like:


The "Advanced Virtual Hosting" supports this type of set-up by using