server {
listen 80;
server_name www.nginx.org nginx.org;
if ($http_host = nginx.org) {
rewrite (.*) http://www.nginx.org$1;
}
...
}
This is a wrong, cumbersome, and ineffective way. The right way is to define a separate server for nginx.org:
server {
listen 80;
server_name nginx.org;
rewrite ^ http://www.nginx.org$request_uri?;
}
server {
listen 80;
server_name www.nginx.org;
...
} |