what is the best and easiest way of applying 301 redirects in aem solution in a project.
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hey,
I see three possible options, depending on where you want redirects to happen:
1) In Apache/Dispatcher - via config
# Map Blank URL to the home path
RewriteCond %{REQUEST_URI} !^/(apps|bin|content|etc|home|libs|system|tmp|var|saml_login|api)
RewriteRule ^/$ https://%{HTTP_HOST}/%{ENV:MARKET}/%{ENV:LANGUAGE} [R=301,L]
2) In AEM - via Sling Mapping config
<short-path
jcr:primaryType="sling:Mapping"
sling:match="*/content*/my-project*/blog-*/(.+).html$"
sling:redirect="/$1"
sling:status="{Long}301" />
3) In CDN - example with Adobe Fastly config
kind: "CDN"
version: "1"
metadata:
envTypes: ["dev"]
data:
redirects:
rules:
- name: redirect-absolute
when: { reqProperty: path, equals: "/page.html" }
action:
type: redirect
status: 301
location: https://example.com/page
- name: redirect-relative
when: { reqProperty: path, equals: "/anotherpage.html" }
action:
type: redirect
location: /anotherpage
Hope this helps,
Daniel
Hey,
I see three possible options, depending on where you want redirects to happen:
1) In Apache/Dispatcher - via config
# Map Blank URL to the home path
RewriteCond %{REQUEST_URI} !^/(apps|bin|content|etc|home|libs|system|tmp|var|saml_login|api)
RewriteRule ^/$ https://%{HTTP_HOST}/%{ENV:MARKET}/%{ENV:LANGUAGE} [R=301,L]
2) In AEM - via Sling Mapping config
<short-path
jcr:primaryType="sling:Mapping"
sling:match="*/content*/my-project*/blog-*/(.+).html$"
sling:redirect="/$1"
sling:status="{Long}301" />
3) In CDN - example with Adobe Fastly config
kind: "CDN"
version: "1"
metadata:
envTypes: ["dev"]
data:
redirects:
rules:
- name: redirect-absolute
when: { reqProperty: path, equals: "/page.html" }
action:
type: redirect
status: 301
location: https://example.com/page
- name: redirect-relative
when: { reqProperty: path, equals: "/anotherpage.html" }
action:
type: redirect
location: /anotherpage
Hope this helps,
Daniel
Is there any solution that the text file has been placed in the
/damadmin#/content/dam/projectName/redirects
It is already implemented but the redirect is not working. what might be the solution in this case?
Hi @sudeepKonjeti,
all supported redirect options are well documented here: https://experienceleague.adobe.com/en/docs/experience-manager-learn/foundation/administration/url-re....
In case you need your Editors to provide redirects, have a look at https://adobe-consulting-services.github.io/acs-aem-commons/features/redirect-map-manager/index.html as well.
Hope this helps,
Daniel