Greg
Greg

Reputation: 21909

Lighttpd vhost setup

tl;dr - How do I reference the conditional regex matches?

I am looking for the simplest vhost setup, but what I am trying doesn't work.

I want:

http://example.dev` => /var/www/dev/example/
http://website.dev` => /var/www/dev/website/

I have tried:

server.document-root = "/var/www/"
$HTTP["host"] =~ "^(.+)\.(.+)$" {
        server.document-root += "%2/%1/"
}

What my method resolves to:

Path: /var/www/%2/%1

Upvotes: 0

Views: 538

Answers (1)

Macattack
Macattack

Reputation: 1990

I suspect that the %1 %2 syntax only works with mod_rewrite. I can't confirm that, but I've only ever used it with mod_rewrite.

A mod_rewrite solution would be the following:

server.document-root = "/var/www/"
$HTTP["host"] =~ "^(.+)\.(.+)$" {
        url.rewrite-once = ( "(.*)" => "/%2/%1$1" )
}

Which should effectively act as if your document root has moved.

*This is untested

Upvotes: 1

Related Questions