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'm having a problem with my vhosts using regex. When I use the following code, I get a 404 not found:

$HTTP["host"] =~ "(^|\.)example\.com$" {

However, when I explicitly set it to the following, I can get to my site:

$HTTP["host"] == "" {

Does anyone know why this is happening? The documentation is fairly sparse.

share|improve this question

I think I've found my problem. I'm using port 8080 instead of port 80 and I read the somewhat hidden text on the very bottom of the documentation page that states:

(Doesn't work for you? If you're not running on the default port, $HTTP["host"] will have the port number appended and the above reg-ex won't match it, since the trailing "$" means "the-string-ends-this-way".)

share|improve this answer

You already found the problem; now fix it by using ($|:) or (:[0-9]+)?$ instead of $.

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.