Hi @zendarkke ,
In Apache Sling, when defining mappings in the etc/map configuration, it's important to understand that the fragment identifier (the part of a URL that starts with #) is typically not considered part of the path. Therefore, when using sling:match to define mappings, it won't directly match the fragment identifier.
However, you can use Sling rewrite rules to achieve a similar effect. Here's how you can approach it:
Define a Rewrite Rule: Create a rewrite rule that captures the fragment identifier and appends it as a request parameter.
Update the Mapping: Adjust the mapping to consider the appended request parameter.
Here's an example:
Step 1: Define Rewrite Rule
You can define a rewrite rule to capture the fragment identifier and append it as a request parameter. Add this rule in the Apache Sling Rewrite Rules configuration (/apps/yourapp/config/org.apache.sling.rewriter.impl.RewriterImpl) or a similar location:
# Rewrite rule to capture fragment identifier and append as request parameter
RewriteRule ^/content/website/(.*)#(.*)$ /content/website/$1?fragment=$2 [NE,L,QSA]
Step 2: Update Mapping
Now, update your mapping in the etc/map configuration to consider the appended fragment parameter. For example:
# Mapping to match URLs with appended fragment parameter
/some/short/url
sling:internalRedirect:/content/website/(.*)?fragment=#signup
sling:match:$1
With this setup, when a URL like /some/short/url is accessed, the rewrite rule captures the fragment identifier (if any) and appends it as a request parameter (fragment). Then, the mapping matches the URL with the appended fragment parameter, allowing you to perform the desired internal redirect based on the original URL with the fragment identifier.
This approach effectively achieves a reverse mapping of fragment identifier URLs in Apache Sling.