AEM Cloud : HTTPS protocol not getting preserved while redirecting to landing page by accessing domain(brand.com) | Community
Skip to main content
New Participant
May 6, 2022
Solved

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

  • May 6, 2022
  • 1 reply
  • 739 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Anish-Sinha

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]

 

1 reply

Anish-Sinha
Anish-SinhaAccepted solution
Employee
May 7, 2022

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]