Warning: Undefined variable $html in /usr/share/nginx/html/lib/plugins/tabinclude/helper.php on line 240

Warning: Cannot modify header information - headers already sent by (output started at /usr/share/nginx/html/lib/plugins/tabinclude/helper.php:240) in /usr/share/nginx/html/inc/Action/Export.php on line 106

Warning: Cannot modify header information - headers already sent by (output started at /usr/share/nginx/html/lib/plugins/tabinclude/helper.php:240) in /usr/share/nginx/html/inc/Action/Export.php on line 106
nginx_code

Nginx Code

  • force www
  • force non www
  • forcing HTTPs

The right way is to define a separated server for the naked domain and redirect it.

server {
    listen 80;
    server_name example.org;
    return 301 $scheme://www.example.org$request_uri;
}

server {
    listen 80;
    server_name www.example.org;
    ...
}
Note that this also works with HTTPS site.