title: Rewrite location to subdomain in nginx
body: <p>How can I rewrite a subdomain to an application in NGINX?</p>
  
  <p>My configuration is </p>
  
  <pre><code>server {
      listen       80;
      server_name domain.com www.domain.com;
  
      location / {
              include        uwsgi_params;
              uwsgi_pass     127.0.0.1:9001;
              uwsgi_param    UWSGI_PYHOME PATH;
              uwsgi_param    UWSGI_SCRIPT wsgi;
              uwsgi_param    UWSGI_CHDIR PATH;
      }
  
      location /app1 {
              include        uwsgi_params;
              uwsgi_pass     127.0.0.1:9001;
              uwsgi_param    UWSGI_PYHOME PATH2;
              uwsgi_param    UWSGI_SCRIPT wsgi2;
              uwsgi_param    UWSGI_CHDIR PATH2;
              uwsgi_modifier1 30;
      }
  }
  </code></pre>
  
  <p>I want to when access app1.domain.com I got rewrited to domain.com/app1. How can I do this?</p>
  
  <p>Thanks in advance.</p>