Nginx wildcard DNS, with www, without www and with subdomain

Asked

Viewed 542 times

-1

I have an Ngnix server with the following configuration:

server {
    listen 80;
    server_name .dominio.com.br;
    root /home/dominio.com.br/public;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log off;
    error_log  /var/log/nginx/dominio.com.br-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}

I configured in my domain the DNS as follows:

Registration type A with name @ pointing to my server IP Type record CNAME by name www pointing to @ Type record CNAME by name * pointing to @

DNS

If I enter using the address dominio.com.br goes normal. If I enter using the address www.dominio.com.br it redirects to dominio.com.br without the www (I don’t want that to happen) If I enter using the address qualquercoisa.dominio.com.br it accesses normal also without redirecting.

If the person enters any of these links informed above everything should be pointing to the same application as this folder /home/dominio.com.br/public

If the person enters by typing only domain.com.br I will redirect to www.dominio.com.br

Why the www is redirecting to without www? Can you tell me where I’m going wrong or what I’m missing?

1 answer

0

I believe that using the following form can solve your problem.

server_name  *.example.org;
  • Didn’t work no

  • put as ta your dns to become easier

  • DNS added in my question edition.

  • sorry but imgs are blocked here at the company I can’t see ... when I get home I’ll try to help you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.