Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am moving from Apache to Cherokee for some trials

I want to do the redirect in cherokee that i do for Apache:

# Redirect to the WWW canonical name RewriteEngine On RewriteCond %{HTTP_HOST} ! RewriteRule ^{REQUEST_URI} [R=301,L]

But cant find any explanation on how this is done

any help apprectiated

share|improve this question

migrated from Jul 22 '11 at 13:38

This question came from our site for professional and enthusiast programmers.

If it's just one particular domain/sub-domain (or a reasonably small number of domains) you want to redirect, you don't need a separate virtual host (although you can go that route if you like). Here are the steps to redirect a naked domain like to its www sub-domain ( for cherokee v0.99.39:

  1. On your cherokee-admin page (, click the Virtual Servers link on the left nav, and then click the Nickname of the virtual server from which you want to redirect. You probably called this virtual server (or in its Host Match section, it has an entry for *; or it could just be the default virtual server.
  2. Click the Behavior tab.
  3. Click the Add new rule button.
  4. Select Header for the Rule Type.
  5. Select Host for the Header.
  6. Enter ^ for the Regular Expression (and press tab to continue to the next screen). In this scenario we add ^ to the front of the domain from which we want to redirect so we just match the naked domain, and not any sub-domains.
  7. Click the Handler tab.
  8. Select Redirection for the Handler.
  9. Enter /(.*) for the Regular Expression.
  10. Enter$1 (again press tab to allow the ui to process your changes). The $1 indicates where to put the content of the first capturing group from step 9's regular expression.
  11. Click the Save button of the left nav.
  12. Try it out! (Navigate to and validate that you are redirected to with a 301.)
share|improve this answer

There is now a template for this in the web interface of Cherokee (in 1.0.8 at least):

  1. Click vServers on the top navigation
  2. Press the New button
  3. Choose Virtual Server Redirection under Tasks
  4. Start the wizard
  5. Enter for the Origin Domain
  6. Enter for the Target Domain
  7. Hit the Create button

You can redirect multiple domains to the Target Domain also:

  1. Edit the redirect virtual server (It should be the one with a document root of /dev/null)
  2. Go to the Host Match tab
  3. The Method should be set to Wildcards (you could choose Regular Expressions instead)
  4. Press the Add New button to add more domain names
share|improve this answer

The fix will be most likely released soon:

share|improve this answer
up vote 0 down vote accepted

Found the answer

Basically need to create another virtual host and set up the Default handler as a Redirect to the original host.

All the info is here

What I wanted though was the ability to set up redirects without needing to recreate more virtual hosts, ie the way Apache allows me with Mod Rewrite inline

Hopefully they will create a handler for this soon:

i.e. Handler that allows you to choose that and go to the same roote and choice between the or as the main one redirecting the other :) Hope that makes sense.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.