Expand my Community achievements bar.

SOLVED

Change AEM's redirection HTTP status code

Avatar

Former Community Member
I'd like to change the default redirection status code from 302 to 301. According to this, I can do it via OSGi configuration:
 
http://blogs.adobe.com/contentmanagement/2013/08/20/how-to-change-aems-redirection-http-status-code/
 
But I don't appear to have the option in the dialog (I'm on version 5.5.0) (see attached) 
1 Accepted Solution

Avatar

Correct answer by
Level 7

Hi, it seems like all the sling: properties are excluded by default.

"For example, by default the CQ MSM Content Update Action configuration panel specifies under Excluded Page Properties that properties matching the regular expressions jcr:*, sling:* and cq:* will not be updated on rollout."

https://dev.day.com/docs/en/cq/current/administering/multi_site_manager.html#par_title_16

So you need to add the properties that should be rolled out as explained in the article above
and your changes would most probably be applied :)

Good Luck
/Johan

View solution in original post

5 Replies

Avatar

Level 10

Have you tried the sling way as described in the referenced link:
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. 

Avatar

Former Community Member

Yes, I'm aware I could do that. I'd just like to have the option to set it once via OSGi config.

Avatar

Employee

The OSGi configuration was added in version 1.0.2 of the Resource Resolver bundle. See https://issues.apache.org/jira/browse/SLING-2665

This was definitely after 5.5.0 was released. 

Avatar

Former Community Member

In the end, I overlayed the dialog for the redirect and content page templates, and added a page property to set the sling:redirectStatus, so I can content manage the status at page level

<redirectStatus jcr:primaryType="cq:Widget" fieldLabel="Redirect Status" fieldDescription="(if unspecified the redirect will be temporary)" name="./sling:redirectStatus" defaultValue="{Long}302" type="select" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"> <temporary jcr:primaryType="nt:unstructured" text="Temporary" value="{Long}302"/> <permanent jcr:primaryType="nt:unstructured" text="Permanent" value="{Long}301"/> </options> </redirectStatus> <redirectStatusHint jcr:primaryType="cq:Widget" ignoreData="{Boolean}true" name="./sling:redirectStatus@TypeHint" value="Long" xtype="hidden"/>

 

This works well. The last thing I'd like to be able to do is include this property when I roll out the page to live copy sites, but it doesn't copy over when I rollout. Is there some configuration so that I can include the extra page property?

 

 

 

Avatar

Correct answer by
Level 7

Hi, it seems like all the sling: properties are excluded by default.

"For example, by default the CQ MSM Content Update Action configuration panel specifies under Excluded Page Properties that properties matching the regular expressions jcr:*, sling:* and cq:* will not be updated on rollout."

https://dev.day.com/docs/en/cq/current/administering/multi_site_manager.html#par_title_16

So you need to add the properties that should be rolled out as explained in the article above
and your changes would most probably be applied :)

Good Luck
/Johan