Expand my Community achievements bar.

Introducing Adobe LLM Optimizer: Own your brand’s presence in AI-Powered search and discovery
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
Community Advisor and Adobe Champion

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
Community Advisor and Adobe Champion

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

Community Advisor

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?

Avatar

Community Advisor and Adobe Champion

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