I have a server (itself on a subdomain) with wildcard DNS pointing to it. The server is running Lighttpd and PHP.
I need requests to http://any-subdomain.server.example.com
to rewrite to http://server.example.com/site/any-subdomain
and be served from there. It has to be completely transparent to the user.
Here's my relevant config:
$HTTP["host"] =~ "^(.*)\.server\.example\.com$" {
url.rewrite-once = ( "^(.*)" => "/site/%1/$1" )
}
It seems to work except for subfolders, which get redirected to subdomain.server.example.com/site/subdomain/subfolder
and then 404's.