Expand my Community achievements bar.

301 redirect in aem 6.5

Avatar

Level 2

Hi,

I have around 1000 pages which is something like this-

source page- content/abc/content/at/de/test/insights/articles/equity/2020/robotics-automation-at.html

I want to implement 301 redirect 

target page- content/abc/content/at/de/test/insights/articles/equity/2020/robotics-automation.html

 

how can I implement this.

3 Replies

Avatar

Level 2

Yes, I checked this link and saw below details-

Limitations of 301 Redirects in Redirect Map Manager:

301 Redirect Map is really a cool feature but it has some limitations.

  1. This is one to one mapping and we can not manage a regex here. So if we have 1000 of URL’s need to redirect in a particular pattern you can not manage in Redirect Map. For this, you have to manage it in Apache level. So create a file and add all the regex redirect URL’s like shown below.

RewriteRule ^/en/index(.*)html$  /en/home.html [R=301,L]

Include the file in the rewrite file of a particular website.

but my point here-

1)- Which file I need to create?

2)- I have to redirect url that has country code suffix from all the URLs to a URL without country suffix before .html

content/abc/content/at/de/test/insights/articles/equity/2020/robotics-automation-at.html

content/abc/content/au/de/test/insights/articles/equity/2020/robotics-automation-au.html

 

Shall I write a rewrite rule with a single regex in dispatcher file and will it work?

 

 

 

Avatar

Community Advisor

Hi @Anoop345 As mentioned by @Siva_Sogalapalli - This will help you out by implementing the 301 based redirects using redirect map or vanity redirect.

 Implement Redirects in Dispatcher:

Implement the 301 based redirects in rewrite file under /etc/httpd/conf.d/rewrites/*

exmaple:

RewriteRule  ^/content/abc/content/at/de/test/insights/articles/equity/2020/robotics-automation-at.html https://%{SERVER_NAME}/content/abc/content/at/de/test/insights/articles/equity/2020/robotics-automation.html [R=301,NC,L]

 

** {SERVER_NAME} - if you have variable for domain name use this variable or you can use domain name.

** Make sure to call this rewrite file in vhost file.

** check the syntax - service httpd configtest -> if syntax is OK restart the httpd service.

** You can use excel sheet to add 1000 redirects with source/destination path + Redirect flag like below:

Rajakp_0-1637050677851.png

** To test all the redirects - use macro-script in excel.

 

Please let us know if you have any issues post implementing the redirect.