title: Can Sling mappings be restricted to requests with host header
body: <p>I would like to selectively apply <a href="http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html" rel="nofollow">Sling mappings</a> defined in sling:Mapping nodes under /etc/map.publish and can't get the behaviour I would like.</p>
  
  <p>Essentially, I would like the <strong>mapping rule to trigger only when the host header matches</strong> the request.</p>
  
  <p>I am currently using sling:Mapping nodes under /etc/map.publish to map resource paths to short URLs in the response.</p>
  
  <p>So under <code>/etc/map.publish/http/myapp</code> I would have the following node:</p>
  
  <pre><code>&lt;jcr:root ...&gt;
      jcr:primaryType="sling:Mapping"
      sling:internalRedirect="/content/company/app/en"
      sling:match="app.company.com
  &lt;/jcr:root&gt;
  </code></pre>
  
  <p>What I would like is that when a user requests:</p>
  
  <pre><code>http://app.company.com/content/company/app/en/page.html
  </code></pre>
  
  <p>The urls in the response (when mapped) will return in the form:</p>
  
  <pre><code>http://app.company.com/page.html
  </code></pre>
  
  <p>The reason for this difference in inbound and outbound urls is because I have Apache rewriting URLs for different device types.</p>
  
  <p>However, when a request with a different host header arrives, such as:</p>
  
  <pre><code>http://localhost:4502/content/company/app/en/page.html
  </code></pre>
  
  <p>I do not want the URLs to be mapped according to that rule.  Right now, it is being mapped to </p>
  
  <pre><code>http://app.company.com/page.html
  </code></pre>
  
  <p>It seems as though the mapping is strictly resolves the resource using considering the host/port.  Then when mapping urls during output a "best match" is found and used.  I would like the map() to behave like the resolve() if possible.</p>