AEM Dispatcher Filters, checking for more than one selector | Community
Skip to main content
Level 2
November 21, 2023
Solved

AEM Dispatcher Filters, checking for more than one selector

  • November 21, 2023
  • 2 replies
  • 1782 views

I want to add a filter rule that allows urls of a certain /path that also end with .cfm.gql.json

 

In this case, the extension is json, and the selectors are cfm and gql. The issue is that I'm not sure how to how to check that both selectors are in the url, I only know how to check if one of them is in it using /selectors '(cfm|gql)'

 

I also want to avoid using a wildcard like /*.cfm.gql.json because that doesn't seem safe, and I don't think including selectors in the /path is a good choice either. Would appreciate any help!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by aanchal-sikka

Hello @ishaja 

 

Please refer to https://blog.developer.adobe.com/writing-better-aem-dispatcher-filters-f23b391624a9

Section: "Matching Multiple Selector Attributes"

 

Excerpt:

There is no way to express a Dispatcher filter that all selectors must match or that allows only a certain filter order. As a workaround, you can either

  • deny selectors with /selectors ‘’
  • match /url instead of /selectors
  • Make sure your custom servlets check for valid combinations of selectors
  • Write a servlet filter
  • Add additional rewrite rules using mod_rewrite at vhost level

 

The link has examples of both /url and /selectors

2 replies

A_H_M_Imrul
Community Advisor
Community Advisor
November 22, 2023

@ishaja 

Here is a possible solution but with dispatcher rewrite

 

RewriteEngine On # Disallow URLs ending with .json and containing .cfm or .gql RewriteCond %{REQUEST_URI} \.json$ [NC] RewriteCond %{REQUEST_URI} \.(cfm|gql) [NC] RewriteRule ^ - [F]

 

 Please let me know if that serves your purpose.

 

aanchal-sikka
Community Advisor
aanchal-sikkaCommunity AdvisorAccepted solution
Community Advisor
November 22, 2023

Hello @ishaja 

 

Please refer to https://blog.developer.adobe.com/writing-better-aem-dispatcher-filters-f23b391624a9

Section: "Matching Multiple Selector Attributes"

 

Excerpt:

There is no way to express a Dispatcher filter that all selectors must match or that allows only a certain filter order. As a workaround, you can either

  • deny selectors with /selectors ‘’
  • match /url instead of /selectors
  • Make sure your custom servlets check for valid combinations of selectors
  • Write a servlet filter
  • Add additional rewrite rules using mod_rewrite at vhost level

 

The link has examples of both /url and /selectors

Aanchal Sikka