title: What am I missing for this CQ5/AEM URL rewriting scenario?
body: <p>I basically want short URLs to get resolved and HTML pages to be generated with short URLs for a CQ5 website. So far short URLs are getting mapped to long URLs as expected, but links in the generated HTML pages are not getting shortened. </p>
  
  <p>For example, I am expecting the <code>src</code> attribute of the following <code>&lt;script&gt;</code> tag:</p>
  
  <pre><code>&lt;script type="text/javascript" src="/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/style/clientlibs.1395978029951.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>To be shortened to:</p>
  
  <pre><code>&lt;script type="text/javascript" src="/style/clientlibs.1395978029951.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>But it is not and remains intact. <code>href</code> attributes in anchor elements are not getting shortened either.</p>
  
  <p>In JCR, the website is stored under <code>/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/</code> and I have configured my <code>/etc/hosts</code> and Apache config files to make it accessible via <code>http://site-1:4503</code> in my local development environment.</p>
  
  <p>I have defined the following URL mappings:</p>
  
  <pre><code>{
     "jcr:primaryType":"sling:Folder",
     "http":{
        "jcr:primaryType":"sling:Folder",
        "site-1.4503":{
           "sling:internalRedirect":[
              "/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae"
           ],
           "jcr:primaryType":"sling:Mapping",
           "redirect":{
              "sling:internalRedirect":[
                 "/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/$1",
                 "/$1"
              ],
              "jcr:primaryType":"sling:Mapping",
              "sling:match":"(.+)$"
           }
        },
        "site_1.4503":{
           "sling:internalRedirect":[
              "/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/home.html"
           ],
           "jcr:primaryType":"sling:Mapping",
           "sling:match":"site-1.4503/$"
        }
     }
  }
  </code></pre>
  
  <p>When I test this mapping in JCR Resolver (<code>http://localhost:4503/system/console/jcrresolver</code>), it is working as expected. For example,</p>
  
  <pre><code>/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/style/clientlibs.1395978029951.js
  </code></pre>
  
  <p>is mapped to</p>
  
  <pre><code>http://site-1:4503/style/clientlibs.1395978029951.js
  </code></pre>
  
  <p>and</p>
  
  <pre><code>http://site-1:4503/style/clientlibs.1395978029951.js
  </code></pre>
  
  <p>is resolved to:</p>
  
  <pre><code>JcrNodeResource, 
  type=cq:ClientLibraryFolder,
  superType=null, 
  path=/content/foo/c0/06/9d/3d93a858-efb4-4619-8f9e-5edc65d0f5ae/style/clientlibs
  </code></pre>
  
  <p>Also when I go to <code>http://site-1:4503/style/clientlibs.1395978029951.js</code> in my browser, the JS file is rendered as expected.</p>
  
  <p>However when I view the HTML source for the home page, as I mentioned earlier, none of the long URLs are rewritten to their shortened forms.</p>
  
  <p>Any ideas what am I missing here?</p>