Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Vanity URL - Exclude from dispatcher pass through redirects

Avatar

Level 2

Hi,

 

We have a Vanity URL setup at page level on AEM and with the default settings, it works fine.

https://helpx.adobe.com/experience-manager/kb/ams-dispatcher-manual/disp-vanity-url.html 

 

I also have a "resource mapping" setup to define redirects, and vanity URLs so that the internal structure of AEM content is hidden from the visitors. To achieve this, I have set up a passthrough redirect at the dispatcher's end (similar to https://github.com/adobe/aem-guides-wknd/blob/main/dispatcher/src/conf.d/rewrites/rewrite.rules#L21-...).

 

Due to this scenario, vanity URLs are getting 404 though there are part of vanity URL file.

 

Is it possible to exclude vanity URLs from these redirects or is any alternative solution available?

 

 

4 Replies

Avatar

Employee Advisor

Can you please provide an example, what it actually does and what you are expecting to achieve.

Avatar

Level 2

Hi @Jörg_Hoh 

 

Let's say I have a site http://www.example.com and a page with the content path /content/businessunit/branch/locale/home/about.html

I have a setup vanity URL for the page "about" as "vanity-aboutus". Now the page can be accessed at http://www.example.com/vanity-aboutus

Now, additional two things -

[1] I have set up a sling mapping for URL shortening as follows:

sling:internalRedirect="/content/businessunit/branch/locale/home((\.html)|/(.*))"
sling:match="www.example.com/$3"

[2] Pass through AEM content paths for enabling proper dispatcher caching.

RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/bin
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{REQUEST_URI} !^/home
RewriteCond %{REQUEST_URI} !^/libs
RewriteCond %{REQUEST_URI} !^/saml_login
RewriteCond %{REQUEST_URI} !^/system
RewriteCond %{REQUEST_URI} !^/tmp
RewriteCond %{REQUEST_URI} !^/var
RewriteRule ^/(.*)$ /content/businessunit/branch/locale/home/$1 [PT,L]

I configure AEM to process the vanity before sling map (using the property Vanity Path Precedence in resource resolver).
Now, due to sling mapping and dispatcher redirect rules, the vanity URLs pass through the site home page and resulting in a 404 response.

Avatar

Level 2

Is this issue resolved. I am also facing the same issue where the vanity URL configured for a page is not working and dispatcher is trying to prefix it with the tree path like any other page. 

 

Is there a way to escape the rewrite rules for the vanity URLs alone? 

Avatar

Level 2

Hi,

 

I suggest to try below line for above example -

 

RewriteCond %{REQUEST_URI} !^/vanity

As your vanity path is starting with vanity  so this can be utilized as a pattern to skip such kind of URLs from being rewrite.

 

Add above line before 

RewriteRule ^/(.*)$ /content/businessunit/branch/locale/home/$1 [PT,L]

 

Thanks