code: public String substituteLinkForRootPath(CmsObject cms, String rootPath) {
  
          String siteRoot = OpenCms.getSiteManager().getSiteRoot(rootPath);
          if (siteRoot == null) {
              // use current site root in case no valid site root is available
              // this will also be the case if a "/system" link is used
              siteRoot = cms.getRequestContext().getSiteRoot();
          }
          String sitePath;
          if (rootPath.startsWith(siteRoot)) {
              // only cut the site root if the root part really has this prefix
              sitePath = rootPath.substring(siteRoot.length());
          } else {
              sitePath = rootPath;
          }
          return substituteLink(cms, sitePath, siteRoot, false);
      }
docs: Returns a link <i>from</i> the URI stored in the provided OpenCms user context
  <i>to</i> the VFS resource indicated by the given root path, for use on web pages.<p>
  
  The result will contain the configured context path and
  servlet name, and in the case of the "online" project it will also be rewritten according to
  to the configured static export settings.<p>
  
  Should the current site of the given OpenCms user context <code>cms</code> be different from the
  site root of the given resource root path, the result will contain the full server URL to the target resource.<p>
  
  @param cms the current OpenCms user context
  @param rootPath the VFS resource root path the link should point to
  
  @return a link <i>from</i> the URI stored in the provided OpenCms user context
  <i>to</i> the VFS resource indicated by the given root path