Redirect non www to www version on digitalocean?


#1

Hello, I can redirect domain on normal shared hosting accounts But I am completely noob on digitalocean. How can I Redirect non www to www version on digitalocean?


(Robert Dean) #2

You will most likely want to setup two server blocks in your virtual host conf file.

Something like the reverse of this.

server {
    #listen 80 is default
    server_name www.example.com;
    return 301 $scheme://example.com$request_uri;
}

server {
    #listen 80 is default
    server_name example.com;
    ## here goes the rest of your conf...
}

(Alec Joy) #3

What is the issue you’re trying to solve with this if you don’t mind me asking? does the www-less domain not work?


(Jeff Atwood) #4

Covered here


(Jeff Atwood) #5