provide 301 redirect in aem 6.5

Avatar

Avatar

sreenu539

Avatar

sreenu539

sreenu539

02-10-2020

Hi,

 

I know Out of the box AEM "redirectTarget" page property does "302" redirect. I am really not sure how AEM doing internally.

 

Client requirement is to have option for both "301" and "302". 

I saw following as options ( more solutions and best solutions are welcome)

http://www.sgaemsolutions.com/2018/

 

http://adobeaemtips.blogspot.com/2017/10/aem-page-redirect-sling-model.html

 

Please let me know, if these are needed or does AEM 6.5 will take care of redirect status if I have "redirectStatus page property value as "301" or "302" or any other solutions.

 

Thanks,

Sri

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

vanegi

Employee

Avatar

vanegi

Employee

vanegi
Employee

04-10-2020

This redirection of request URLs in AEM can be configured at the Sling level, typically in the mapping configuration under /etc/map node. There are two ways of changing the status code:

 

1) By sling:status property

 

You can use sling:status property to set a specific status code for a particular redirection. Here is an example:

 

/etc/map

      +-- http

           +-- example.com.80

           |    +-- sling:redirect = "http://www.example.com/"

           |    +-- sling:status = "301"

 

Please check the document [0] for more details.

 

[0]: https://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html

 

 

2) 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.

Answers (3)

Answers (3)

Avatar

Avatar

raj_mandalapu

Avatar

raj_mandalapu

raj_mandalapu

05-10-2020

Hi @sreenu539 

Both solutions will work, choosing one on others depends on the requirements if you have hundreds of pages and want to give control to the content authors then selecting this at page property level will help, you do not need to request TechOps guys to add redirection for every page.

If you what pages you want to redirect then I prefer rewrite URL's is the best solution.

Avatar

Avatar

Nikhil-Kumar

MVP

Avatar

Nikhil-Kumar

MVP

Nikhil-Kumar
MVP

05-10-2020

@sreenu539 
You can achieve it by using etc/map. Like mapping the input request and redirecting to the destination output page.
Below is an example which might help you:

https://aemsimplifiedbynikhil.wordpress.com/2020/08/26/shortening-of-url-using-etc-map/

Thanks,
Nikhil

Avatar

Avatar

Ravi_Pampana

MVP

Avatar

Ravi_Pampana

MVP

Ravi_Pampana
MVP

02-10-2020

Hi, 

 

We can handle easily at dispatcher level by passing R=301 to the redirect rules.

 

Ex:

RewriteRule (.*)$ https://%{SERVER_NAME}$1/ [R=301,QSA,L]

RewriteRule ^/test.html /test.html#anchor [NE,R=301,L]