Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

AEM Dispatcher filter - how to make case insensitive?

joej47544984
Level 2
Level 2

Hi I'm sure this question must have been answered or explained somewhere but I've not found it yet

The Adobe product pages explain Configuring Dispatcher.  I'd like to filter out requests based on file extension similar to the example in the documentation,

Example filter: Using Regular Expressions

This filter enables extensions in non-public content directories using a regular expression, defined here between single quotes:

1

/005  {  /type "allow" /extension '(css|gif|ico|js|png|swf|jpe?g)' }

I'd like our rule to be case insensitive, so that files uploaded, with naming such as 'foo.jpg', 'foo.JpeG' and 'foo.JPG' are all allowed by a filter rule like this.  As it's a regular expression, I would expect to be able to amend the regex example to '(css|gif|ico|js|png|swf|jpe?g)/i' but this doesn't seem to work.

Does anyone know how to make this extension rule case insensitive?

7 Replies
Arun_Patidar
Community Advisor
Community Advisor

HI,

I am not sure if below is helpful in your case, worth to give a try.

Mastering the AEM Dispatcher Part 2: Case Insensitive URLs

joej47544984
Level 2
Level 2

Thanks @Arun Patidar

I've seen the (excellent) blogs you linked to, but those concern the Apache mod_rewrite module.  I'm working in the dispatcher.any file  (i.e. configuring Apache mod_dispatcher).

The Adobe filter documentation (see my link above) says

so I hoped a simple tweak to the regex "...defined here between single quotes..." would make the filter ignore case.  But my suggestion above doesn't work.  How do I write a dispatcher.any filter that ignores case?

Arun_Patidar
Community Advisor
Community Advisor

Hi,

I am not sure how to do that, I am unable to test in my machine but you can try below if helps

'(css|gif|ico|js|png|swf|jpe?g)'/i

'(css|gif|ico|js|png|swf|jpe?g)'i

joej47544984
Level 2
Level 2

thanks for your suggestions Arun Patidar

My reading of the documentation's "...regular expression, defined here between single quotes..." was that the regex literally had to be 'between...quotes' but i gave your suggestions a try nevertheless (presumably you saw what i said I had tried in the original question above?).

Unfortunately neither of those worked.

Jörg_Hoh
Employee
Employee

As suggested I would just convert all extensions to lowercase using mod_rewrite. Although the dispatcher might support regular expressions, I don't assume that it will support all modifiers you are used from the PCRE.

Jörg

joej47544984
Level 2
Level 2

Thanks @Jörg Hoh

I'm not looking to support all modifiers from the PCRE just this one (case-insensitivity)  and as a starting point, if I can avoid having to maintain configuration in two different places to achieve one thing, then I would rather do that.

As a follow-up question, do you know where can I reference exactly what flavour of regex the dispatcher does support?

thanks

joej47544984
Level 2
Level 2

If i can't pin down a regex case insensitive flag for the Dispatcher, amending the filter's regex to something like the following seems to work, (though it's not particularly readable)