Expand my Community achievements bar.

SOLVED

AEM Cloud : HTTPS protocol not getting preserved while redirecting to landing page by accessing domain(brand.com)

Avatar

Level 1

When I am accessing brand.com site, below redirects are happening

 

Actual:

https://www.brand.com(Status code : 302) -> http://www.brand.com/content/brand/in/en/landingpage(Status code : 302 Internal redirect) -> https://www.brand.com/content/brand/in/en/landingpage(Status code : 302) -> http://www.brand.com/en/landingpage(Status code : 302 Internal redirect) -> https://www.brand.com/en/landingpage(Status code : 304)

 

 

Expected :

 

There should not be redirect from https to http
https://www.brand.com ->

https://www.brand.com/content/brand/in/en/landingpage ->

https://www.brand.com/en/landingpage

 

Dispatcher Rewrite rule:

 

RewriteCond %{HTTP_HOST} brand.com
RewriteRule ^/?$ /content/brand/in/en/landingpage [R,L]

 

RewriteCond %{REQUEST_URI} !^/apps
RewriteCond %{REQUEST_URI} !^/content
RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{HTTP_HOST} brand.com
RewriteRule ^/(.*?)(/?)$ /content/brand/in/$1.html [PT,L,NC]

 

 

Please provide your inputs/suggestion to resolve this issue.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @sankar07 ,

I can see there are multiple 302 redirects happening which is not needed. Try below rules and modify as per your need. 1st to make sure the redirection is to https and 2nd one to append /content/brand. More [R] redirects are not needed in my opinion. You can have PT flag instead:-

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^/?$ https://brand.com%{REQUEST_URI} [L,R]

RewriteCond %{HTTP_HOST} ^brand.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^/$ https://brand.com/en/landingpage [R=301,L] RewriteCond %{REQUEST_URI} !^/apps RewriteCond %{REQUEST_URI} !^/content RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{HTTP_HOST} brand.com RewriteRule ^/(.+) /content/brand/in/$1 [PT,L,NC]

 

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Hi @sankar07 ,

I can see there are multiple 302 redirects happening which is not needed. Try below rules and modify as per your need. 1st to make sure the redirection is to https and 2nd one to append /content/brand. More [R] redirects are not needed in my opinion. You can have PT flag instead:-

RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^/?$ https://brand.com%{REQUEST_URI} [L,R]

RewriteCond %{HTTP_HOST} ^brand.com$ [NC]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ^/$ https://brand.com/en/landingpage [R=301,L] RewriteCond %{REQUEST_URI} !^/apps RewriteCond %{REQUEST_URI} !^/content RewriteCond %{REQUEST_URI} !^/etc
RewriteCond %{HTTP_HOST} brand.com RewriteRule ^/(.+) /content/brand/in/$1 [PT,L,NC]