lighttpd configuration to redirect subdomains
Support this website by purchasing prints of my photographs! Check them out here.For my NeoInvoice project, all requests to the server's sub-domains are sent right to the main server. This means someone can go to www.neoinvoice.com
, ex1.neoinvoice.com
, etc. Search engines don't like to see duplicate content on web servers, cookies being saved on one sub-domain aren't accessible to another, there are all sorts of problems with this. Down the road we do plan on setting up sub-domains for every company (in which case the application will do redirects, not the server), but in the mean time we want to disable all sub domains (except for www
).
Adding this rule to your lighttpd configuration file will redirect all sub-domains to the www. sub-domain. People going to the main domain will also be redirected to the www. sub-domain.
$HTTP["host"] =~ "domain.com" {
$HTTP["host"] != "www.domain.com" {
url.redirect = (
"^(.*)$" => "http://www.domain.com$1",
)
}
}