Hi Team,
We received a customer request on below requirement,
If we hit the domain (eg: abc.com) it should redirected to particular dam page /content/dam/demo.pdf
It will be helpful, if someone could provide me the exact rewrite rule for this.
Thanks in advance!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi, if you are using CDN and this is a temporary request from customer then redirect at CND level would be easy to implement but if it is a permanent request then like mentioned by others rewrite rule needs to implement at dispatcher level.
hi @AnushaAt
you can add this mod_rewrite rewrite rule to your Dispatcher configuration (e.g., in rewrites/rewrite.rules or your virtual host configuration):
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^/$ /content/dam/demo.pdf [L,R=301]Alternative (with PT flag for internal rewriting):
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^/$ /content/dam/demo.pdf [PT,L]Here is the explanation of flags:
| Flag | Purpose |
| ^/$ | Matches only the root path (/) |
| R=301 | Sends a permanent redirect (301) to the browser |
| PT | Pass Through - internally rewrites without sending redirect to browser |
| L | Last rule (stops processing further rules) |
Super small example of a virtual host (just for demo purpose):
<VirtualHost *:80>
ServerName abc.com
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^/$ /content/dam/demo.pdf [L,R=301]
</VirtualHost>Create a rewrite map file in DAM at /content/dam/redirectmaps/mysite-redirectmap.txt
Add the mapping:
/ /content/dam/demo.pdfConfigure the Apache rewrite rule to use this map (managed via managed-rewrite-maps.yaml)
With this approach, you enable business users to manage redirects without requiring code deployment.
Hi Team,
Currently implementing the suggested rewrites, will update here once it is working.
Thanks for the suggestion!
Regards,
Anusha
Hello @AnushaAt ,
You don’t need anything complex here. A single rule that maps the bare domain / to /content/dam/demo.pdf is enough.
If your site is fronted by Apache HTTPD (classic Dispatcher setup), add this to your vhost (inside the right <VirtualHost> block and after RewriteEngine On.
# If the request is just the bare domain (root), redirect to the DAM asset
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ /content/dam/demo.pdf [R=301,L]
R=301 = permanent redirect (search-engine friendly; cached by browsers).R=302 first.Example for HTTPS-only virtual host:
<VirtualHost *:443>
ServerName abc.com
# … SSL and Dispatcher config …
RewriteEngine On
# Redirect root to DAM asset
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^$ /content/dam/demo.pdf [R=301,L]
# …other rules…
</VirtualHost>
Hello @AnushaAt
If this is AEMaaCS, you can also do this at the CDN Level.
The AEM-managed CDN provides a redirection solution at the Edge level thus reducing round trips to the origin.
The Server-side Redirects feature allows you to configure the redirect rules in the AEM project code and deploy using the Config Pipeline.
kind: "CDN"
version: "1"
data:
redirects:
rules:
- name: redirect-root-to-dam
when:
reqProperty: path
equals: "/"
action:
type: redirect
status: 301
location: /content/dam/demo.pdf
Reference :
https://experienceleague.adobe.com/en/docs/experience-manager-learn/foundation/administration/url-re...
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/con...
Hi, if you are using CDN and this is a temporary request from customer then redirect at CND level would be easy to implement but if it is a permanent request then like mentioned by others rewrite rule needs to implement at dispatcher level.
Views
Likes
Replies
Views
Likes
Replies