papermail
By:
papermail

Add www to domain

May 6, 2014 1.9k views
I have Ghost 0.4.2 set up on http://www.thepapermail.com. However, when you enter http://thepapermail.com, you are still presented with the same general page. None of my links work with that, though, because I have Ghost configured to use www before the URL. I tried adding a cname with www pointing to @, but that didn't work. Then I added an A record with www pointing to my server's IP address. That didn't work either. Does anyone know of a way to force prepend www to the domain?
3 Answers
You can force a redirect to www by editing the nginx configuration like so:


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

client_max_body_size 10M;

location / {
proxy_pass http://localhost:2368/;
proxy_set_header Host $host;
proxy_buffering off;
}
}


This is found in:


/etc/nginx/conf.d/default.conf


Let us know how it goes!
Worked perfect, Andrew. One more thing: should I remove any of the records I added in DNS settings?
Glad it worked!

No, you should keep DNS records pointing both www.thepapermail.com and thepapermail.com to that IP address.
Have another answer? Share your knowledge.