I want Lighttpd to display a different page for internal clients and the default page for everyone else.
Between these two links, I have an idea of what I want to do but am not sure of the RegEx I would need to restrict clients using a hostname of [http://]192.168.0.? or [http://]192.168.?.? to a different page. I’ve been using the following code in lighttpd.conf:
server.document-root = "/var/www/sites"
$HTTP["host"] == "RegExHere" {
server.document-root = "/var/www/setup"
}
…where for ‘RegExHere’ I have tried a variety of attempts such as:
192\.168\.0\.\d{1,3}(\s|$))+
192\.168\.
[192.168.[0-9]+.]
192\.168\.[0-9]+.[0-9]+$
…and various combinations thereof. I have no idea whether I’m close, but regardless it only shows me the default page.
Can anyone advise where I may be going wrong please?
Thanks in advance!
You have to use the =~ syntax to match a regex. Change
$HTTP["host"] == "RegExHere"to$HTTP["host"] =~ "RegExHere"and one of those regexs should work.^192\.168\.\d{1,3}\.\d{1,3}$should do it.Found this article on it http://blog.evanweaver.com/2006/06/07/regular-expressions-in-lighttpd-host-redirects/
edit: I think you need to use $HTTP[“remoteip”] instead of $HTTP[“host”] and it looks like you can do it without regexes.
http://forum.lighttpd.net/topic/27