Friday, November 24, 2017

Rewrite Rules with PT(Pass Through) Flag is not working in AEM Dispatchers - Adobe Experience Manager(AEM)

Rewrite Rules with PT(Pass Through) Flag is not working in AEM Dispatchers - Adobe Experience Manager(AEM)

How to define SEO/User friendly URL's in Adobe Experience Manager(AEM)


The Rewrite Rules with PT Flag helps us to define the SEO/User friendly URL's by hiding the internal URL's.

Let consider a scenario - The product URL should be rewritten to SEO/User friendly URL.

The internal product URL is - /en/test/pdp/book.html?id=123, this URL is not SEO/User friendly as the title of the

The URL should be rewritten to /en/test/Sample_Book/book/pdp.html?id=123 internally without changing the Browser URL

Rewrite_Rule_with_PT_flag


Dispatcher Changes:


Add the below Rewrite Rule in dispatcher virtual host

RewriteCond %{QUERY_STRING} ^id=(.*) [NC]
RewriteRule ^/en/test/(.*)/(.*)/pdp.html$ /en/test/pdp/$2.html?id=%1 [PT,L]

The new URL's - /en/test/Sample_Book/book/pdp.html?id=123  were returning 404 response after enabling the rewrite rules, based on the analysis Dispatcher sending the request to AEM(Adobe Experience Manager) with  browser specific URL and not not the internal URL configured in the rewrite rule.

The Publisher was displaying the following error

GET /en/test/Sample_Book/book/pdp.html HTTP/1.1] org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Resource /content/en/test/Sample_Book/book/pdp.html not found

To fix the issue, set DispatcherUseProcessedURL to 1 in httpd.conf file - This tells Dispatcher to use the pre-processed URL

PT flag in the rewrite rule allows Apache to pass the rewritten URL to Adobe Experience Manager(AEM) dispatcher



No comments:

Post a Comment