Non-www to www nginx redirect

Add this small block of code into your server{} block to redirect all non-www to the www version of your website.

1
2
3
if ($host != 'www.samhamilton.co.uk' ) {
rewrite ^/(.*)$ http://www.samhamilton.co.uk/$1 permanent;
}

Proudly powered by Hexo and Theme by Hacker
© 2024 Sam Hamilton