Web-server – How to redirect multiple domains to a single domain in lighttpd

lighttpdredirectredirectionweb-server

If I have the following domains in lighttpd:
domain1.com
domain1.co.uk
domain2.com
domain2.co.uk

How do i redirect all these to to 'domain.com'?

ie:
domain1.co.uk/some-path/ redirects to domain.com/some-path/
and
domain2.com/some-other-path/ redirects to domain.com/some-other-path/

Thanks.

Best Answer

Something like:

$HTTP["host"] =~ "firsthost.example.com|secondhost.example.com|otherhost.example.net" {
  url.redirect = ( "^/(.*)" => "http://realdomain.example.org/$1" )
}

should work - as covered in the man page ;)

Related Topic