Need to redirect from acme.com to www.acme.com with nginx? No problem … just add a virtual host declaration for the non-www that redirects like this:
1 2 3 4 5 |
server { listen 80; server_name acme.com; rewrite ^/(.*) http://www.acme.com/$1 permanent; } |
or if you want to add to an existing vhost:
1 2 3 |
if ( $host != 'www.domain.com' ) { rewrite ^/(.*)$ http://www.domain.com/$1 permanent; } |