Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Automatic sub-domains with lighttpd mapping to a specific folder (See related posts)

Using lighttpd's mod_evhost with

# %% => % sign
# %0 => domain name + tld
# %1 => tld
# %2 => domain name without tld
# %3 => subdomain 1 name
# %4 => subdomain 2 name
#


$HTTP["host"] =~ "jasonhoffman.org" {
evhost.path-pattern        = "/home/jah/public/%3/"
}

Comments on this post

intranation posts on Sep 26, 2005 at 12:22
To make this work without returning 404 errors on "www.domain.com" (because likely the "www" directory doesn't exist), use the following snippet:

$HTTP["host"] =~ "domain\.com" {

    # automatic subdomain mapping
    $HTTP["host"] !~ "www\.domain\.com" {
        evhost.path-pattern         = "/home/username/public_html/%3/"
    }
    # rest of conditional (doc roots etc.) goes here...
}


Note that this only works on Lighttpd 1.4+ (I think).

You need to create an account or log in to post comments to this site.


Related Posts