AEM 301 Redirect Handler

In this article, I am going to explain how can we implement 301 redirects in AEM, when someone requested a page instead of that if you want to redirect the user to some other page without affecting SEO then we can use 301 redirect handler

This is very useful when it comes to migration project’s, there are some pages which are on legacy system and other pages are on AEM, and if you want to serve legacy pages from the AEM domain then you can  implement 301 redirect handler

Let us take a simple example, I have initially published an article in grey area.in domain after some point of time I thought of migrating entire content to the keys and strokes domain without affecting SEO, what I did was added some rewrite rules at apache level, you can use Apache if you want to migrate entire thing but what if I want to redirect only certain pages, then we need to implement 301 redirections at a page level, the next section covers how can we do this in AEM

greyarea

301 RedirectHandler In AEM

Create a new property in the page properties called custom redirect or 301 redirect path whatever you want, I have used xtype= pathfield for this, but if you have want to configure external pages then use textfield and while constructing URL you need to use externalizer

Create a new page and configure redirect path, test this in preview or disabled mode

 

geometrixx

The below code reads page path and setup custom headers to the response