Jump to content
Froxlor Forum
  • 0

nginx: two server{} declaration for one domain


mnt

Question

Posted

I want redirect non-www domain to www with nginx.

Example: test.com -> www.test.com

 

Is possible to have two server declaration for one domain in nginx config?

Example:

server {
    listen       80;
    server_name  test.com;
    return       301 http://www.test.com$request_uri;
}

server {
    listen       80;
    server_name  www.test.com;
    ...
}

3 answers to this question

Recommended Posts

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...