Set the Preferred Domain for your Ghost Blog
Unlike in WordPress where you set a site url in the admin area and WordPress handles all the www/non-www redirects for you – ghost does not (yet).
Setting up the redirect is fairly easy, ssh into your server and open the nginx configuration for your site. Add one server block for each redirect you want to have:
As mentioned above, if you want another redirect add it in a seperate server block. Note that instead of rewriting that part of the url that differs, like we would do for apache, the new url is completely returned. This allows us to specify a HTTP response status (301 – permanent in this case) and is also faster than a rewrite.
After saving and closing the nginx.conf you will have to restart the webserver (either
nginx -t && nginx -s reload or
service nginx restart) and verify that we get the correct HTTP response:
curl -I http://www.alpipego.com/
This should output something like:
HTTP/1.1 301 Moved Permanently Server: nginx/1.1.19 Date: Tue, 21 Jan 2014 22:14:52 GMT Content-Type: text/html Content-Length: 185 Connection: keep-alive Location: http://alpipego.com/