Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Implement redirects with the content

Avatar

Level 2

Hi All,

We have some pages under /c/ folder like example /content/we-retail/us/en/c/page1 and /content/we-retail/us/en/c/page2 etc.

We would like to remove /c/ from the page and should redirect to /content/we-retail/us/en/page1.html with serving the same content as /content/we-retail/us/en/c/page1.

 

We need to do it for all locales so there may be number of pages.

Considering any page under /c/ folder should remove /c/ and then page should redirect.

 

Could you please let us know how to implement this and please suggest us on what are the possible options.

Is there any way to implement via dispatcher rewrite rule.

 

We are using AEM 6.4.5 version

Please let us know.

 

Thanks

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can achieve this through Apache/Dispatcher redirects and etc mapping for page links

  • Redirect the user to the final URL through Apache
  • Enable a PT rule in Apache to send the required URL to AEM
  • Enable etc mapping in AEM tho handle the page links

Refer the following URL for more details - https://www.albinsblog.com/2020/07/configure-sling-mapping-for-resource-resolution-in-adobe-experien...

Regards

Albin I

www.albinsblog.com

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

You can achieve this through Apache/Dispatcher redirects and etc mapping for page links

  • Redirect the user to the final URL through Apache
  • Enable a PT rule in Apache to send the required URL to AEM
  • Enable etc mapping in AEM tho handle the page links

Refer the following URL for more details - https://www.albinsblog.com/2020/07/configure-sling-mapping-for-resource-resolution-in-adobe-experien...

Regards

Albin I

www.albinsblog.com

Avatar

Community Advisor

If you use CDN then just handle this at the CDN or use below on your Apache for blank redirects:

 

RewriteRule ^(?i)/content/we-retail/us/en/c/(.*)$ /content/we-retail/us/en/$1 [R=301,L]

 

The above rewrite rule will remove "c" from the url.

Let me know if you have any questions.

 

Thanks,

Singaiah

 

Hi Singaiah,

We tried this rule, page is redirecting but with 404 No resource found and may be because it is trying to find the page under /c/ where it is not existed.

RewriteCond %{REQUEST_URI} ^/(.*)/(.*)/c/(.*)$

RewriteRule ^/(.*)/(.*)/c/(.*)$ /$1/$2/$3 [L,R=301]

As we need to achieve for all country locales.

Avatar

Community Advisor
remove the RewriteCond and you just need the RewriteRule. Also, can you check the network tab and see where it is going?