I am currently looking for a software/web development job preferably as a Rails-based developer.
Please email me at weston@westonganger.com. Thanks in advance for any leads!

Redirecting Www To Non-www Domains On Nginx And Apache

Posted by Weston Ganger

Redirecting a www address to a non-www address or vice versa is important for SEO. Heres how to set it up on Nginx and Apache in the most efficient way.

# Nginx - Redirect www to non-www
server {
  server_name www.solidfoundationwebdev.com;
  return 301 $scheme://solidfoundationwebdev.com$request_uri;

# Apache - Redirect www to non-www
  ServerName www.solidfoundationwebdev.com
  <IfModule mod_alias.c>
    Redirect permanent / http://solidfoundationwebdev.com/

If you need to do non-www to www then just change the above code to suit the need.

Related External Links:

Article Topic:Software Development - Linux

Date:September 01, 2015

Recommended Posts