August 20, 2013

How to change AEM’s redirection HTTP status code?

Redirection of request URLs in AEM can be configured at the Sling level, typically in the mapping configuration under /etc/map node. Depending on the requirements, there are times when customers would like to change the default HTTP status code for redirection. And here you will find two ways of changing the status code:

The sling:status way

Documented in already, you may use sling:status property to set a specific status code for a particular redirection. To extend the example given on the page linked above:

      +-- http
           |    +-- sling:redirect = ""
           |    +-- sling:status = "301"

Via OSGi configuration

Another way, which really sets the default for all redirection, is to configure the status code at the OSGi bundle level. In the OSGi console, browse the the Configuration page and locate:

“Apache Sling Resource Resolver Factory”

and change the redirect status field to whatever status code is appropriate (highlighted in diagram below).

Sling redirection status code


4:50 PM Permalink

How to send an AEM dispatcher flush request via cURL

In the “Invalidating Cached Pages from AEM” document on, there is a brief section covering how to invalidate dispatcher cache manually. It only talks about sending HTTP requests to the dispatcher and it briefly touches on the format. So, where’s the quick (and dirty, if you will) command? Anything for me to copy and paste and get the job done?

Here you go:

curl -H "CQ-Action: Activate" \ 
     -H "CQ-Handle: /content/bar" \ 
     -H "Content-Length: 0" \
     -H "Content-Type: application/octet-stream" \ 

Of course you will have to replace the content path and the host/port.

If you ever need a “hook” to get a custom set of files to be invalidated from the dispatcher, for whatever reason, put the above into a script in any *nix environments (where cURL is supported) should do the job for you. Oh, did I forget to mention that you can actually trigger a command from an AEM workflow? You get the idea :P


4:09 PM Permalink