AEM Redirection Not working | Community
Skip to main content
Level 3
February 16, 2024
Solved

AEM Redirection Not working

  • February 16, 2024
  • 5 replies
  • 1196 views

Hi Team I have a requirement to redirect every requests from  https://mypage.mywebsite.com/properties/shoppingpage-pointe.html and https://mypage.mywebsite.com/properties/the-cart.html to https://mypage.mywebsite.com/properties/shoppingpage-pointe-the-cart.html

 

I tried with below code, but it is not working as expected. 

Could you please guide me on what to be done.

 

<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 https://mypage.mywebsite.com/properties/shoppingpage-pointe.html https://mypage.mywebsite.com/properties/shoppingpage-pointe-the-cart.html
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine On
Redirect 301 https://mypage.mywebsite.com/properties/the-cart.html https://mypage.mywebsite.com/properties/shoppingpage-pointe-the-cart.html
</IfModule>

Best answer by Imran Khan

@vineetham123 

Please try below rule once

RewriteRule /properties/(shoppingpage-pointe|the-cart)* /properties/shoppingpage-pointe-the-cart.html [R=301,L]

5 replies

ayush-anand
Level 4
February 16, 2024

Hi @vineetham123 

 

You can try the below rewrite rules in your rewrite rules file

 

RewriteCond %{REQUEST_URI} ^/properties/(shoppingpage-pointe|the-cart).html
RewriteRule ^/(.*)$ /properties/shoppingpage-pointe-the-cart.html  [PT,L]

 

Regards

Ayush

Imran Khan
Community Advisor
Imran KhanCommunity AdvisorAccepted solution
Community Advisor
February 16, 2024

@vineetham123 

Please try below rule once

RewriteRule /properties/(shoppingpage-pointe|the-cart)* /properties/shoppingpage-pointe-the-cart.html [R=301,L]

Raja_Reddy
Community Advisor
Community Advisor
February 16, 2024

Hi @vineetham123 

You can try using the following code 

<IfModule mod_rewrite.c>
RewriteRule ^properties/shoppingpage-pointe\.html$ /properties/shoppingpage-pointe-the-cart.html [R=301,L]
RewriteRule ^properties/the-cart\.html$ /properties/shoppingpage-pointe-the-cart.html [R=301,L]
</IfModule>

This code uses regular expressions to match the URLs and redirect them to the desired URL. 

arunpatidar
Community Advisor
Community Advisor
February 16, 2024

You can try 

RewriteRule ^/(properties)/(shoppingpage-pointe|the-cart).html$ /$1/shoppingpage-pointe-the-cart.html [R=301,L]
Arun Patidar
kautuk_sahni
Community Manager
Community Manager
February 16, 2024

@vineetham123 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.

Kautuk Sahni