Expand my Community achievements bar.

SOLVED

How to redirect a url in AEM

Avatar

Level 3

I have 2 webpages 

1)https://www.samplepage.com

2)https://www.samplepage.com/index.html 

I have a requirement where i need to redirect to https://www.samplepage.com when  clicked https://www.samplepage.com/index.html . Could you please explain what could be done?

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@vineetham123 

RewriteCond %{REQUEST_URI} ^/index.html$
RewriteRule ^/(.*) / [R=301,L]

View solution in original post

7 Replies

Avatar

Correct answer by
Community Advisor

@vineetham123 

RewriteCond %{REQUEST_URI} ^/index.html$
RewriteRule ^/(.*) / [R=301,L]

Avatar

Community Advisor

As part of rewrite rules fine under /dispatcher/src/conf.d/rewrites folder

Avatar

Community Advisor

Hi @vineetham123 

 

Below rule worked for me 

 

RewriteCond %{REQUEST_URI} ^/index.html$
RewriteRule ^(.*)index\.html?$ "/$1" [R=301,L]

 

Jagadeesh_Prakash_0-1707817544962.png

 

Avatar

Community Advisor

@vineetham123  Just in case if you want to validate it online. use below URL

https://htaccess.madewithlove.com?share=b3f964bd-48be-43aa-948d-d354ab4e2a97

 

And also where to write this condition is as below. If you are on AEMaaCS write it in the vhost files located at below location 

/dispatcher/src/conf.d

If you are on AMS / on-prem you can write a custom rewrite rule and load in vhost files

path  /dispatcher/src/conf.d/rewrites 

 

<IfModule mod_rewrite.c>
RewriteEngine on
Include conf.d/rewrites/rewrite.rules

RewriteCond %{REQUEST_URI} ^/index.html$
RewriteRule ^(.*)index\.html?$ "/$1" [R=301,L]

</IfModule>

 

 

Avatar

Community Advisor
RewriteCond %{REQUEST_URI}  ^/index.html$
RewriteRule /(.*) / [R=301,L]
 
RewriteCond %{REQUEST_URI}  ^/(.*)$
RewriteRule /(.*) /content/project_name/us/$1.html [PT,QSA,NE,L]

@Jagadeesh_Prakash  We have to have internal pass through to point one of the page.

cc @vineetham123 

Avatar

Community Advisor

@Imran__Khan  But I think the ask is "i need to redirect to https://www.samplepage.com when  clicked https://www.samplepage.com/index.html ." I am hoping the internal pass through is already managed