Posts tagged "http status code"

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Ā http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html 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:

/etc/map
      +-- http
           +-- example.com.80
           |    +-- sling:redirect = "http://www.example.com/"
           |    +-- 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