NGINX www/non-www separation

MtK

Verified User
Joined
Aug 2, 2007
Messages
412
[solved] NGINX www/non-www separation

Hey,
how can we separate the www.domain.com from the domain.com settings in order to be able to redirect one to the other?

MtK
 
Last edited:
in the /usr/local/directadmin/data/templates/custom/nginx_server.conf:
Code:
server
{
        listen |IP|:|PORT_80|;
        |MULTI_IP|

        server_name |DOMAIN|;
        rewrite ^(.*) http://www.|DOMAIN|$1 permanent;
}

server
{
|CUSTOM|

        listen |IP|:|PORT_80|;
        |MULTI_IP|

        server_name www.|DOMAIN| |SERVER_ALIASES|;
since this is done in the template this will work for all domain...
 
Back
Top