2012-07-23 12:43:04 +02:00
|
|
|
# www to non-www redirect -- duplicate content is BAD:
|
|
|
|
# https://github.com/h5bp/html5-boilerplate/blob/5370479476dceae7cc3ea105946536d6bc0ee468/.htaccess#L362
|
|
|
|
# Choose between www and non-www, listen on the *wrong* one and redirect to
|
2018-11-23 14:45:12 +01:00
|
|
|
# the right one -- https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/#server-name-if
|
2012-07-23 12:43:04 +02:00
|
|
|
server {
|
|
|
|
# don't forget to tell on which port this server listens
|
2014-08-21 01:31:37 +02:00
|
|
|
listen [::]:80;
|
2012-07-23 12:43:04 +02:00
|
|
|
listen 80;
|
2013-01-12 20:33:17 +01:00
|
|
|
|
2012-07-23 12:43:04 +02:00
|
|
|
# listen on the www host
|
|
|
|
server_name www.example.com;
|
|
|
|
|
|
|
|
# and redirect to the non-www host (declared below)
|
|
|
|
return 301 $scheme://example.com$request_uri;
|
|
|
|
}
|
|
|
|
|
2012-02-03 13:58:16 +01:00
|
|
|
server {
|
2015-04-01 23:10:30 +02:00
|
|
|
# listen [::]:80 accept_filter=httpready; # for FreeBSD
|
2013-11-20 21:40:02 +01:00
|
|
|
# listen 80 accept_filter=httpready; # for FreeBSD
|
2015-04-01 23:10:30 +02:00
|
|
|
# listen [::]:80 deferred; # for Linux
|
|
|
|
# listen 80 deferred; # for Linux
|
2014-08-21 01:31:37 +02:00
|
|
|
listen [::]:80;
|
2013-11-20 21:40:02 +01:00
|
|
|
listen 80;
|
2012-02-03 13:58:16 +01:00
|
|
|
|
2012-07-22 23:31:54 +02:00
|
|
|
# The host name to respond to
|
2012-02-03 13:58:16 +01:00
|
|
|
server_name example.com;
|
|
|
|
|
|
|
|
# Path for static files
|
|
|
|
root /sites/example.com/public;
|
|
|
|
|
2015-12-01 03:38:42 +01:00
|
|
|
# Specify a charset
|
2012-02-03 13:58:16 +01:00
|
|
|
charset utf-8;
|
|
|
|
|
|
|
|
# Custom 404 page
|
|
|
|
error_page 404 /404.html;
|
|
|
|
|
2013-11-22 11:49:07 +01:00
|
|
|
# Include the basic h5bp config set
|
|
|
|
include h5bp/basic.conf;
|
2012-02-03 13:58:16 +01:00
|
|
|
}
|