Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

AEM Dispatcher filter - how to make case insensitive?

Avatar

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?

8 Replies

Avatar

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



Arun Patidar

Avatar

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?

Avatar

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



Arun Patidar

Avatar

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.

Avatar

Employee Advisor

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

Avatar

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

Avatar

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)

Avatar

Level 3

I am disappointed to see the dispatcher still does not allow for case insensitive extensions.  Or at least on v4.3.3 which is what I am using. @joej47544984   Can you share your regex?  I don't see it in the post above.