The reverse mapping happens automatically following the resolve rules. I have mentioned the configuration which i used in the original question. I am not using sling output rewrite and not manipulating through component code.
This use case is my project requirement. We have internal links with #identifier appended at the end. The links are getting converted properly but the #identifier at the end is getting truncated.
For Example. I have a image with URL. The URL is internal path and i configured like /content/abc.html#identifier. Once the page gets loaded the internal URL is getting mapped to http://domain/abc.html truncating the #identifier.