title: NGINX mask a url redirect
body: <p>I have a url <code>api.domain.com</code> that I am trying to redirect to <code>domain.com/api</code> BUT I want to preserve the look that it's still <code>api.domain.com</code></p>
  
  <p>I have tried the following </p>
  
  <pre><code>server {
          listen 80;
          server_name api.domain.com;
  
          location ~ ^/ {
                  rewrite ^/(.*) https://domain.com/api/$1 break;
          }
  }
  </code></pre>
  
  <p>But when I hit an endpoint eg <code>api.domain.com/user/1</code> in the browser it displays as <code>domain.com/api/user/1</code>.</p>
  
  <p>Is it possible to get the domain to visually stay as <code>api.domain.com/user/1</code></p>