Q: How to redirect non-www to www using Nginx?

Nginx Redirect

Answer:

To forward non-www traffic to www, use the following server block :

server {
    listen       80;
    server_name  example.org;
    return       301 http://www.example.org$request_uri;
}

server {
    listen       80;
    server_name  www.example.org;
    ...
}

Replace the text in red with your own domain name.

    No comments found for this tutorial, be the first to leave a comment!

Answered by
Double

Last updated on
Aug 16, 2016

Share