Expand my Community achievements bar.

Join us in celebrating the outstanding achievement of our AEM Community Member of the Year!
SOLVED

How to provide solution in aem for 301 redirects in 6.5

Avatar

Level 2

what is the best and easiest way of applying 301 redirects in aem solution in a project.

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 9

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

View solution in original post

4 Replies

Avatar

Correct answer by
Level 9

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

Avatar

Level 2

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?