Adding this code in your server block
if ($host ~* ^www\.(.*)){ set $host_without_www $1; rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent; }
# unless the request is for a valid file, send to bootstrap
if (!-e $request_filename) { rewrite ^(.+)$ /index.php?q=$1 last; }
# enable this
location ~ /\.ht { deny all; }