title: Subdomain is always redirecting to the main domain
body: <p>I wanted to set up a staging version of our Wordpress website, so I copied everything, added a new nginx config, and pointed the subdomain to the server (this all exists on the same ubuntu server).</p>
  
  <p>I added basic authentication to staging.mydomain.com, and when I go to the URL on any computer (and incognito) I do get the auth login popup, but when I fill it in, I get redirected straight to mydomain.com. I had this exact issue previously and it was a caching issue, but I don't think that's the case here which is why I think I'm missing something in my Nginx configuration.</p>
  
  <p>Here's the nginx config for the main website:</p>
  
  <pre><code>limit_req_zone $binary_remote_addr zone=one:10m rate=14r/s;
  limit_req_zone $binary_remote_addr zone=login:10m rate=2r/s;
  
  server {
      listen 80;
      server_name mydomain.com www.mydomain.com;
      rewrite        ^ https://$server_name$request_uri? permanent;
  }
  
  server {
       listen 443;
  
       server_name mydomain.com www.mydomain.com;
  
       root /var/www/mydomain;
  
       index index.php;
  
  
       location = /wp-login.php {
           limit_req   zone=login  burst=5 nodelay;
           include fastcgi_params;
           fastcgi_intercept_errors on;
           include snippets/fastcgi-php.conf;
           fastcgi_pass unix:/run/php/php7.0-fpm.sock;
       }
  
       location = /favicon.ico {
               log_not_found off;
               access_log off;
       }
  
       location = /robots.txt {
               allow all;
               log_not_found off;
               access_log off;
       }
  
       location / {
               try_files $uri $uri/ /index.php?$args;
               proxy_read_timeout 300;
       }
  
       # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
       location ~ \.php$ {
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/run/php/php7.0-fpm.sock;
       }
  
       location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
               expires max;
               log_not_found off;
       }
  
       ssl     on;
       ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
       ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
       keepalive_timeout   70;
  
       ssl_prefer_server_ciphers On;
       ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
       ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
  
  }
  </code></pre>
  
  <p>And here's the nginx config for staging.mydomain.com:</p>
  
  <pre><code>server {
      listen 80;
          server_name staging.mydomain.com www.staging.mydomain.com;
      rewrite        ^ https://staging.mydomain.com$request_uri? permanent;
      return 301  https://staging.mydomain.com;
  }
  
  server {
      listen 443;
  
      server_name staging.mydomain.com www.staging.mydomain.com;
  
          root /var/www/mydomain-staging;
  
          index index.php index.html;
  
          auth_basic          "Admin Area";
          auth_basic_user_file    /etc/apache2/.htpasswd;
  
      location = /wp-login.php {
          limit_req   zone=login  burst=5 nodelay;
              include fastcgi_params;
              fastcgi_intercept_errors on;
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/run/php/php7.0-fpm.sock;
      }
  
          location = /favicon.ico {
                  log_not_found off;
                  access_log off;
          }
  
          location = /robots.txt {
                  allow all;
                  log_not_found off;
                  access_log off;
          }
  
          location / {
                  try_files $uri $uri/ /index.php?$args;
          proxy_read_timeout 300;
          }
  
          # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
          location ~ \.php$ {
                 include snippets/fastcgi-php.conf;
                 fastcgi_pass unix:/run/php/php7.0-fpm.sock;
          }
  
          location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                  expires max;
                  log_not_found off;
          }
  
      ssl     on;
      ssl_certificate /etc/letsencrypt/live/staging.mydomain.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/staging.mydomain.com/privkey.pem;
      keepalive_timeout   70;
  
      ssl_prefer_server_ciphers On;
      ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
  
  }
  </code></pre>