I'm using Cherokee webserver and I wish to redirect all requests to www.domain.com to domain.com without creating a separate virtual server to redirect requests.
In the Host Match
section, I've set www.domain.com and domain.com as accepted domains in the wildcard mode. Now I assume that I need to create a rule with the Redirection
handler with these settings:
Type: External
Regular Expression: ^/(.*)$
Substitution: http://domain.com/$1
The question is, what type of rule do I select? I've tried the redirection rule with this setting: ^www.domain.com/(.*)$
EDIT: ANSWER
(As ServerFault isn't letting me answer the question yet)
Finally figured it out. Create a rule of the Header
type and pick the Host
header. Then match this regular expression: ^www.domain.com$
. Set the handler to an external redirection with the Regular Expression: ^/(.*)$
and the Substitution: http://domain.com/$1
.
Do a Graceful Restart and you should be all set!