Expand my Community achievements bar.

Not exposing the "/content/dam/project" and "/content/project " in redirect urls

Avatar

Level 4

Hi Everyone,

I have a requirement for not exposing the "/content/dam/project" and "/content/project" in the rendered html so users do not get to see the internal paths.

If we need to sling redirect URL mapping. How can we achieve it? Please explain with example.

We have used a method to remove the /content/project from all <a href> of the HTML using the below method.

  /**
     * This method is used for reverse map the urls on page.  
     * @retrun- if url start with /content it remove the /content/proj& append html to url.
     * @ retrun- if url is null, blank or not start with /content than it return the same url.
     * 
     */
    public String getResourceResolverMapURl(SlingHttpServletRequest slingRequest, String  url ){


        if(url!=null && !"".equals(url) && (url.startsWith("/content/proj") || url.startsWith("/content/dam"))){
            String extension = "";
            int index = url.lastIndexOf('.');
            if (index >= 0) {
                extension = url.substring(index+1).toUpperCase();
            }
            if(extension.isEmpty()){
                url=url+".html"; 
            }
            return slingRequest.getResourceResolver().map(slingRequest, url );
           }
           else
         {
            return url;
         }
     }

We have 6500 url s still getting redirected to /content/project or /content/dam . 

Any help would be greatly appreciated.

Thanks

1 Reply