Note that there are some explanatory texts on larger screens.

plurals
  1. POMatching domains with regex for lighttpd mod_evhost (www.domain.com / domain.com / sub.domain.com)
    text
    copied!<p>I'm playing about with <a href="http://en.wikipedia.org/wiki/Lighttpd" rel="nofollow noreferrer">lighttpd</a> on a small virtual private server. I two domains pointing to the server. I am using the latest version of lighttpd and mod_evhost on Ubuntu 8.10.</p> <ol> <li><p>I'm trying to set up a rule such that if anyone requests <strong>domain.com</strong> or <strong>www.domain.com</strong> they get served from <em>/webroot/domain.com/www/</em></p></li> <li><p>Similarly, if anyone requests <strong>sub.domain.com</strong> they get served from <em>/webroot/domain.com/sub/</em></p></li> <li><p>If people requests <strong>fake.domain.com</strong> (where <em>/webroot/domain.com/fake/</em> does not exist) I would like them served from <em>/webroot/domain.com/www/</em></p></li> </ol> <p>The third requirement isn't quite so important, I can deal with people requesting subdomains that don't exist being served from the server document root of <em>/webroot/server.com/www/</em> even if they requested <strong>fake.domain.com</strong></p> <p>I've included the relevant parts of my lighttpd.conf file below:</p> <pre><code>server.document-root = "/webroot/server.com/www/" // regex to match sub.domain.com $HTTP["host"] =~ "\b[a-zA-Z]\w*\.\b[a-zA-Z]\w*\.\b[a-zA-Z]\w*" { evhost.path-pattern = "/webroot/%0/%3/" } // regex to match domain.com $HTTP["host"] =~ "\b[a-zA-Z]\w*\.\b[a-zA-Z]\w*" { evhost.path-pattern = "/webroot/%0/www/" } </code></pre> <p>So where am I going wrong? At the moment, all requests to <strong>*.domain.com</strong> and <strong>domain.com</strong> are being served from <em>/webroot/domain.com/www/</em></p> <p>I'd appreciate any help you guys could offer and if I've left anything relevant out please tell me!</p> <p>Cheers, Rob</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload