Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.

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

Avatar

Level 2

 

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!

14 Replies

Avatar

Employee

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

Avatar

Level 2

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!

Avatar

Community Advisor

Avatar

Employee

@sai_charanAr In the documentation mentioned by @arunpatidar especially "Upon review and approval, the marketing team can publish the text file." is worth to mention - maybe you somehow did not publish your file from author to publish (so that this file is downloadable from publish under that path configured).

Avatar

Level 2

Thanks, @krystiannowak  The text file has been published from author to publish, and it’s accessible via the dispatcher url too

— but the issue still persists.

Avatar

Employee

@sai_charanAr Probably in httpderror logs you should be able to see progress and messages if your map files were able to be fetched, or if there was any problem and e.g. empty map fallback had been created because of that.

Avatar

Level 2

@krystiannowak  i checked the dispatcher logs, and it looks like the managed rewrite map is functioning correctly.

From the logs:

The dispatcher successfully detects the map file redirects_external.map from the DAM path: /content/dam/project/redirects/redirects_external.txt.

The system is evaluating the map every 30 seconds, and TTL is correctly set to 300 seconds.

The log lines confirm that the map file is being reused until TTL expires:

ttl = '300' not exceeded for previously generated map - will SKIP map 'redirects_external.map' regeneration for now
There are no errors or fallbacks to empty maps, and the he

Avatar

Employee

@sai_charanAr That is indeed misterious. Maybe - for debugging purposes only - you could "statically" put your map file together with your configs and use https://httpd.apache.org/docs/2.4/rewrite/rewritemap.html#txt plain text maps format and check if that works. If no, it means something in your rewrite rules needs to be checked, if yes, then something wrong is with the file transfer into dbm format. Would be also good to check if any line in that file does not exceed 1024 characters, as there is such default limit in https://github.com/apache/httpd/blob/2.4.x/modules/mappers/mod_rewrite.c#L232

Avatar

Level 2

@krystiannowak 

I’ve tried using the txt: format and gave the path directly in the rewrite map rule as etc/httpd/conf.d/rewrites/redirects_external.txt, but it results in a “file not found” error. Since this is on AEM as a Cloud Service, we don’t have access to place static files manually on the filesystem.

Is there a way to include such static rewrite map files through code or configuration that works in the cloud setu

Avatar

Employee

@sai_charanAr and something like:

RewriteMap external_redirects "txt:conf.d/rewrites/redirects_external.txt"

wouldn't work for you (assuming if you add the redirects_external.txt file along the configuration files)?

Avatar

Level 2

yes @krystiannowak  i have added txt file through yaml configurations

 

Avatar

Employee

@sai_charanAr but you need to include that in the configs for testing, in yaml it's when you have it already tested ok and if you want to have DBM option of it (but after having it successfully tested with TXT option from config-local file)

Avatar

Employee

@sai_charanAr Please also note that (as both documentation https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/con... and tutorial https://experienceleague.adobe.com/en/docs/experience-manager-learn/foundation/administration/implem... state) the RewriteMap directive needs to be included in rewrites used by given vhost intended to be used for this functionality, so it might be sensible to include it (or embed those directives) as early/as high as possible in those vhost configurations so that other rules do not mistakenly override the ones from the rewrite map configured for this mechanism.

Avatar

Level 2

Hi @krystiannowak currently the rewrite Map redirects were included in the project specific vhost file and i have tried acs-commons rewrite maps approach also it is also having the same issue where the map is created, and system is checking the map
based on ttl configured in yaml file but not sure the content is generated in map file and rewrites are not working. I tried to put the static map file that also din't work unfortunately. is there any precende adjusted for the rewrite rules?

RewriteMap external_redirects dbm=sdbm:/tmp/rewrites/external_redirects.map

RewriteCond ${external_redirects:%{REQUEST_URI}} != "" RewriteRule ^(.*)$ ${external_redirects:%{REQUEST_URI}} [R=301,L]