Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

AEM Dispatcher Filters, checking for more than one selector

Avatar

Level 3

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!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

2 Replies

Avatar

Community Advisor

@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.

 

Avatar

Correct answer by
Community Advisor

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