Question about redirecting example for forcing a host name

Fred Palmer fred at studionow.com
Tue Aug 28 20:12:47 MSD 2007


I found an Nginx example for forcing the host name and wanted to know if
this is the best way to do it.  Basically I have several domains, some are
misspellings of our primary domain and we want them to all go to our primary
domain.  So I found this example:

server {
  listen 80;
  server_name example.com www.example.com;

  if ($host != 'example.com' ) {
      rewrite  ^/(.*)$  http://example.com/$1  permanent;
  }
}


Is this the best way?

-- 
Fred Palmer | Senior Software Engineer
615.653.7228 | www.studionow.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20070828/ed412eba/attachment.html>


More information about the nginx mailing list