Project

General

Profile

How to redirect www.example.com to example.com


$HTTP["host"] == "www.example.com" {
  url.redirect  = (
    "^/(.*)" => "http://example.com/$1",
  )
}

Or, to do the same for all domains:


$HTTP["host"] =~ "^www\.(.*)$" {
  url.redirect  = (
    "^/(.*)" => "http://%1/$1",
  )
}

Similar configurations can be used to redirect all .net/.org etc. requests to the dot-com address for the site:


$HTTP["host"] =~ "^(www\.)?example\.(net|org)$" {
  url.redirect  = (
    "^/(.*)" => "http://example.com/$1",
  )
}

Related mailing list postings:

Updated by icy over 5 years ago · 6 revisions