Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.
SOLVED

Rewrite Rule for a specific page

Avatar

Level 3

Hi,

 

I need to redirect a specific page to the home page(root domain).

 

The current redirect for the home page that's below is working fine: Whenever I hot the domain https://www.domain.com serves the page 

## Home Page
RewriteRule ^/?$ /content/appname/us/en/home.html [PT,L]

 

## Rewrite rules for US site root pages
RewriteRule ^/content/appname/us/en/home/(.*).html$ /$1 [R=301,L]

 

There are a bunch of pages that are using Core Breadcrumb component and it follows the structure of:

Home > Devices > DeviceName

 

When Clicking on Home it should redirect to the root (#) instead it is trying to direct to /content/appname/us/en/home.html and in turn is throwing a 404

I added the below rule to redirect to the root (#) but still no luck

 

## Rewrite rule for Home Page
RewriteRule /content/appname/us/en/home.html ^/$ [R=301,L]

 

Can someone suggest how the vice-versa of the below should be working

## Home Page
RewriteRule ^/?$ /content/appname/us/en/home.html [PT,L]

1 Accepted Solution

Avatar

Correct answer by
Level 9

Hi @manasabojja7 

You can try the below one also

RewriteRule ^content/appname/us/en/home.html / [R=301,L]

 

Also if you want to do trial and error please use the below URL 

https://technicalseo.com/tools/htaccess/

 

Hope it helps !

View solution in original post

4 Replies

Avatar

Community Advisor

Dis you try something like this:

RewriteRule ^content/appname/us/en/home\.html$ / [R=301,L]





Esteban Bustamante

Avatar

Community Advisor

Hi @manasabojja7

The same problem is being discussed in here: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/reverse-mapping-in-etc-map... 

You can try to a new node in /etc/map/https/www_domain_com that will map /content/appname/us/en/home.html to root (/) URL. 

{
 "jcr:primaryType": "sling:Mapping",
 "sling:internalRedirect": "/content/appname/us/en/home.html",
 "sling:match": "www.domain.com/$"
}

An example Sling mapping node definition

https://experienceleague.adobe.com/docs/experience-manager-learn/sites/seo/sitemaps.html?lang=en#abs... 

 

 

Avatar

Correct answer by
Level 9

Hi @manasabojja7 

You can try the below one also

RewriteRule ^content/appname/us/en/home.html / [R=301,L]

 

Also if you want to do trial and error please use the below URL 

https://technicalseo.com/tools/htaccess/

 

Hope it helps !

Avatar

Level 3

Thanks @sherinregi @EstebanBustamante 

 

The below rule worked

RewriteRule ^content/appname/us/en/home.html / [R=301,L]

 

Thank you, guys, for the help!