Point Your Www To Non Www With Efficient 301 Redirection For Nginx

Posted By Weston Ganger

<p>This is extremely important for SEO that you do not have your site working for both www and non-www because it will split your ranking between the two as if they were seperate websites</p>
<p>In order to fix this on Nginx the <strong>old and outdated</strong> way is as follows:</p>

server{
  listen 80;
  server_name www.westonganger.com;
  return 301 $scheme://westonganger.com$request_uri;
}
server{
  listen 80; 
  server_name westonganger.com
  ...the rest of your server config...
}

<p>Take note that these instructions are to point www to non-www, if you would like to point non-www to www then just change the server_names and return statements accordingly.</p>

Article Topic:Software Development - Linux

Date:July 08, 2014