April 2, 2020
Estimated Post Reading Time ~

AEM Dispatcher and Vanity URLs

One of the problems that AEM had with vanity URLs was that for each vanity URL there needed to be a filter rule that allowed access to the vanity URL in the Dispatcher. This meant that a content author could create a vanity URL and publish it, but it was not available without updates to the Dispatcher and a restart of the webserver.

However recent Dispatcher versions (since 4.1.9 I think), there’s a new /vanity_urls setting that enables the dispatcher to get a list of vanity urls from the Publish instance and allow these requests if the request fails the Dispatcher filter (see Enabling Access to Vanity URLs for more info). However there’s a few things that need to be done in order to set this up correctly:
Download and install the VanityURLS-Components from Package Share if it’s not already installed on your system (Note: This needs to be installed on your Publish instance)
Go to the user admin of your Publish instance and allow ‘Read’ permission to /libs/granite/dispatcher/content/vanityUrls for the ‘everyone’ group
Add a filter rule in the dispatcher to allow the vanity URL to be called on Publish instance:
/0100 { /type "allow" /url "/libs/granite/dispatcher/content/vanityUrls.html" }

Add a caching rule to prevent caching of this URL:
/0001 { /type "deny" /glob "/libs/granite/dispatcher/content/vanityUrls.html" }

Add the vanity_urls configuration to the farm:

/vanity_urls { 
     /url "/libs/granite/dispatcher/content/vanityUrls.html" 
    /file "/tmp/vanity_urls"
    /delay 300 
}
Restart your webserver

It’s worth noting that the file defined at the /file setting is not automatically created\updated at the time interval set at /delay, but only when a request is made that fails the /filter rules of your Dispatcher. On fail, it checks to see if the file is there – if it’s not there then genrate and use it, otherwise if it is there and is not older than /delay seconds use it, or finally if it it is older than /delay seconds update it from the Publish instance and then use it.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.