Description: Cherokee is a flexible, very fast, lightweight Web server. It is implemented entirely in C, and has no dependencies beyond a standard C library. It is embeddable and extensible with plug-ins. It supports on-the-fly configuration by reading files or strings, TLS/SSL (via GNUTLS or OpenSSL), virtual hosts, authentication, cache friendly features, PHP, custom error management, and much more.
Keywords: cherokee web server httpd http

## Index → Cookbook

## Cookbook: Redirections

Every now and then a redirection example is requested in the mailing list. This recipe is meant to be a central archive of such examples. Remember there are some more generic examples both in the quickstart and in the redirection handler sections.

There is also a wizard to automatically assist you with redirections. It can be found in the Wizards section of the `Virtual Servers` panel.

### Redirecting www.example.net to example.net

Sometimes a site will have several domains or subdomains pointing to the same official name. For whatever reasons (site statistics, for instance), having many subdomains redirected to a unique subdomain might be desirable. This can be accomplished fairly easily. The general recipe consists in defining a virtual host with the sole purpose of redirecting petitions to the official subdomain. In our example, this could manage *.example.net and the .com and .org variations.

The official name would then be managed by another virtual host (just for example.net). The `redir` virtual host will have a `Default` managed by the `Redirection` handler.

This in turn would define an external redirection with a Regular Expression like ^/(.*)$ and the appropriate Substitution: http://example.net/$1

Keep in mind the redirection has to be external in order for Cherokee to rewrite the the URL. If it wasn’t, the redirection would be applied but no change would be displayed to the users while browsing the site.