Hi Please remind me how to redirect mydomain.com to www.mydomain.com Thanks :)
your default Nginx vhost generated yourdomain.conf has example of redirect for www to non-www that is commented out. Just reverse that for non-www to www and uncomment it
Anyone? My conf file looks like this (first lines of codes): Code: # redirect from non-www to www # uncomment, save file and restart Nginx to enable #server { # listen 80; # server_name MyWebsite.com; # return 301 $scheme://www.MyWebsite.com$request_uri; # } server { server_name Mywebsite.com www.MyWebsite.com; Do I need to remove the www part and uncomment the above and comment the last line?
as mentioned in 2nd post, just reverse the commented out example so something like Code: # redirect from non-www to www # uncomment, save file and restart Nginx to enable server { listen 80; server_name www.MyWebsite.com; return 301 $scheme://MyWebsite.com$request_uri; } server { server_name MyWebsite.com;
I get now this: It says now I should do this: "You may now add content to the directory /usr/local/nginx/html." But my content is in /home/nginx/domains/MyWebsite.com/public
I'm not sure. With "uname -n" I get the hostname I chose when I bought my VPS. So I didn't change the hostname. My registrar (namecheap) points to cloudflare for DNS and cloudflare has 2 Type A entries (localhost (127.0.0.1) and Mywebsite.com (MyVPS_IP)) and 1 Type CNAME entry. So I skipped all the things you describe in step 1 because I didn't feel the need to change my hostname. And then I did the last part of your step 1 and did this: Did I miss something? Just for your information, before the redirecting, I could entry to my website without a problem.
did you check server_name in /usr/local/nginx/conf/conf.d/virtual.conf points to your server hostname output from uname -n ? if not, do that change and restart nginx server the uname -n should be different from your Mywebsite.com or www.Mywebsite.com names otherwise the default virtual.conf will take over your domain i.e. if uname -n is set to www.Mywebsite.com you'd have to show me your cloudflare dns setup/screenshot it too
I checked that and it is correct. My virtual.conf file has the uname -n entry instead of localhost. Got that and it is different. My uname -n is called: server.MyWebsite.com Screenshot is in some seconds in your private message box.
sorry instructions were wrong Code: # redirect from non-www to www # uncomment, save file and restart Nginx to enable server { listen 80; server_name www.MyWebsite.com; return 301 $scheme://MyWebsite.com$request_uri; } server { server_name MyWebsite.com; remove 2nd server_name's www.