title: nginx: all named subdomains to same-name subdirectories, no info back to browser
body: <p>I got tantalizingly close to finding the answer in many preceding posts, but nothing was perfect.  so please forgive the imposition of asking it again.  I think this could be a reasonably common question, so it's worth getting a concise answer.</p>
  
  <p>(1) I (also) want to use subdirectories on my webserver, even if the browser continuously thinks it is dealing with subdomains.  that is, I don't want the browser to receive a 301 from the server [so no return directive].  (2) I don't want to specify a list of domains.  I want it to work for all.</p>
  
  <p>specifically, I want nginx to interpret all $1.example.com as example.com/$1/ without specifying the list of what $1 could be.  thus, <a href="http://funny.example.com/" rel="nofollow">http://funny.example.com/</a> in a browser should always retrieve the same exact page and http code as <a href="http://example.com/funny/" rel="nofollow">http://example.com/funny/</a> .  this should also apply to all subfiles.   <a href="http://funny.example.com/d1/p1.html" rel="nofollow">http://funny.example.com/d1/p1.html</a> should yield the same results as <a href="http://example/funny/d1/p1.html" rel="nofollow">http://example/funny/d1/p1.html</a> .  this is not location remapping, but url remapping.  but, if /var/www/example.com/ is my top directory, presumably this would then serve up /var/www/example.com/funny/d1/p1.html. </p>
  
  <p>from the perspective of the browser, they just happen to see exactly the same page for <a href="http://funny.example.com/" rel="nofollow">http://funny.example.com/</a> and <a href="http://example.com/funny/" rel="nofollow">http://example.com/funny/</a> .</p>
  
  <p>solution appreciated.  </p>