1

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} !=www.domain.com RewriteRule ^ http://www.domain.com%{REQUEST_URI} [R=301,L]

But cant find any explanation on how this is done

any help apprectiated

4 Answers 4

5

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 domain.com to its www sub-domain (www.domain.com) for cherokee v0.99.39:

  1. On your cherokee-admin page (http://127.0.0.1:9090/), 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 domain.com (or in its Host Match section, it has an entry for *domain.com); 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 ^domain.com 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 http://www.domain.com/$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 http://domain.com/ and validate that you are redirected to http://www.domain.com/ with a 301.)
3

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 example.com for the Origin Domain
  6. Enter www.example.com 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
1

The fix will be most likely released soon: http://bugs.cherokee-project.com/722

0

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 http://www.cherokee-project.com/doc/modules_handlers_redir.html

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 www.domain.com and domain.com go to the same roote and choice between the www.domain.com or .domain.com as the main one redirecting the other :) Hope that makes sense.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .