301 Redirects via RewriteMap Not Working – Map File Created but Redirects Failing | Community
Skip to main content
Level 2
April 13, 2025
Solved

301 Redirects via RewriteMap Not Working – Map File Created but Redirects Failing

  • April 13, 2025
  • 1 reply
  • 2421 views

 

Hi all,

I’m trying to implement 301 redirects using RewriteMap in AEM Dispatcher. I’ve followed Adobe’s documentation on pipeline-free URL redirects, and everything seems to be in place — except the redirects aren’t working.

The .txt file is published in DAM with lines like this:

 

After deployment, I can see that the map file is generated at /tmp/rewrites/external_redirects.map and the logs confirm it’s being created successfully.

Here’s what I have in the rewrite.rules file:

 

RewriteMap external_redirects dbm=sdbm:/tmp/rewrites/external_redirects.map RewriteCond ${external_redirects:%{REQUEST_URI}} != "" RewriteRule ^(.*)$ ${external_redirects:%{REQUEST_URI}} [R=301,L]

So far, I’ve:

  • Verified the file is generated and readable

  • Confirmed the keys are using just the path (e.g., /legacy-url)

  • Checked that the map values are full valid URLs

  • Cleared the Dispatcher cache

  • Ensured the source .txt in DAM is published

Despite all this, hitting the short URLs just returns a 404 instead of redirecting.

Has anyone faced something similar or see anything I might be missing in the rewrite logic? Any help would be appreciated.

Thanks!

Best answer by krystiannowak

Hi @krystiannowak ,

Thank you for your response. I have resolved the issue by changing the map name from redirects_external to redirects-external, and it is now functioning correctly. However, I am interested in understanding if there are specific naming conventions for map files. When I used redirects_external, the map was created, and the system checked the map every 300 seconds, but the content remained empty. After renaming the map to redirects-external and adjusting the TTL to 30 seconds, it started working as expected.


@sai_charanar It might have been some other problem, as for RewriteMap both underscores and hyphens are allowed as map names e.g.:

$ cat conf.d/rewrites/rewrite.rules # # This file contains the rewrite rules, and can be customized. # # By default, it includes just the rewrite rules. You can # add rewrite rules to this file but you should still include # the default rewrite rules. Include conf.d/rewrites/default_rewrite.rules RewriteMap redirects_external.map txt:conf.d/rewrites/redirects_external.map.txt RewriteCond ${redirects_external.map:$1} !="" RewriteRule ^(.*)$ ${redirects_external.map:$1|/} [L,R=301] RewriteMap redirects-external.map txt:conf.d/rewrites/redirects-external.map.txt RewriteCond ${redirects-external.map:$1} !="" RewriteRule ^(.*)$ ${redirects-external.map:$1|/} [L,R=302]

both should work. The same is when you have multiple maps as DBMs as configured in Pipeline-free URL Redirects functionality as given in https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/content-delivery/pipeline-free-url-redirects?lang=en#rewrite-map

1 reply

Adobe Employee
April 14, 2025

You can enable the debug log on the apache web server to understand where the redirect rule is failing. https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#logging

Level 2
April 14, 2025

Hi @himanshu,
I checked the logs and noticed that the map file is getting created, but it's completely empty. The source .txt file in DAM does contain valid redirect entries, but these aren’t being picked up or added to the generated map file.

Is there any specific configuration or permission that controls whether the DAM file is read and included in the managed map generation? Let me know if I’m missing any required setup.

Thanks!

arunpatidar
Community Advisor
Community Advisor
April 14, 2025