Skip to main content
Oct 16, 2015 2:27 AM UTC
Solved

Change AEM's redirection HTTP status code

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) 
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Ojjis
OjjisAccepted solution
Level 7
Oct 16, 2015 2:27 AM UTC

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

5 replies

Ojjis
OjjisAccepted solution
Level 7
Oct 16, 2015 2:27 AM UTC

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

Translate
Oct 16, 2015 2:27 AM UTC

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?

 

 

 

Translate
Adobe Employee
Oct 16, 2015 2:27 AM UTC

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. 

Translate
Oct 16, 2015 2:27 AM UTC

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

Translate
smacdonald2008
Level 10
Oct 16, 2015 2:27 AM UTC

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. 

Translate