Solved
How to provide solution in aem for 301 redirects in 6.5
what is the best and easiest way of applying 301 redirects in aem solution in a project.
what is the best and easiest way of applying 301 redirects in aem solution in a project.
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.