Dynamically redirect to appropriate AEM page that is SEO friendly | Community
Skip to main content
Level 2
March 11, 2022
Solved

Dynamically redirect to appropriate AEM page that is SEO friendly

  • March 11, 2022
  • 2 replies
  • 1652 views

I have a case where I need to read URL's and dynamically redirect to the right product listing page. i.e. When hitting a product detail page, if the current product is out of stock, I want to handle logic and redirect to a product listing page that displays products within the same category.

 

What is the best approach to this which is also SEO friendly? Would there be a way to dynamically redirect within the dispatcher or is this something a custom Java Servlet should handle?

 

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by VeenaVikraman

I agree with @anish-sinha , but rather than handling via servlet the best approach (in my personal opinion 🙂) would be a Filter. You can check if the request path is product path and send only those paths for further processing with whatever logic you have to find the valid/active products. Rest of the requests , you can let pass through.

 

eg: 

Hope this helps

 

Veena ✌

2 replies

Anish-Sinha
Adobe Employee
Adobe Employee
March 11, 2022

Hi @akatsuki07 ,

There has to be a logic based on which the page should redirect. To check if the product is out of stock, the call has to go to the server to get the count. Dispatcher won't be able to handle this since there is no identifier that dispatcher would have for out of stock product. 

You can handle this logic in your client side code (javascript) if the product component is using ajax. From there is the response for it is out of stock you can forward the request in js snippet using 

window.location.href="target page path"

Else you can handle it in model class or servlet. 

VeenaVikraman
Community Advisor
VeenaVikramanCommunity AdvisorAccepted solution
Community Advisor
March 11, 2022

I agree with @anish-sinha , but rather than handling via servlet the best approach (in my personal opinion 🙂) would be a Filter. You can check if the request path is product path and send only those paths for further processing with whatever logic you have to find the valid/active products. Rest of the requests , you can let pass through.

 

eg: 

Hope this helps

 

Veena ✌