Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

how to redirect non WWW to WWW with AEM cloud?

TB3dock
Level 8
Level 8

The vhost file only seems to support http (non SSL) traffic.

We want to have:

http://ourdomain.com -> https://www.ourdomain.com

https://ourdomain.com - > https://www.ourdomain.com

https://ourdomain.com/something.html -> https://www.ourdomain.com/something.html.

etc.

 

We would guess something like this would be a start:

 

<VirtualHost *:80>

    ServerName ourdomain.com

    Redirect permanent / http://www.ourdomain.com/

</VirtualHost>

 

<VirtualHost *:80>

    ServerName www.ourdoamain.com

    --- real stuff

 

but what about https?

 

We could also consider using rewrite rules, but should they be to http or https?

e.g.

 

RewriteCond %{HTTP_HOST} ^ourdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.ourdomain.com/$1 [R=301,L]

OR:
RewriteCond %{HTTP_HOST} ^ourdomain\.com$ [NC] RewriteRule ^(.*)$ https://www.ourdomain.com/$1 [R=301,L]
 

We are going from non www to www as it gives us more options around CNAMES which are not supported at Apex, and make it harder to use Azure traffic manager to put up holding pages when AEM cloud is down.

 

1 Accepted Solution
Raja-kp
Correct answer by
Level 7
Level 7

Hi - @TB3dock ,

 

1.Should have proper SSL certificate for WWW domain.

2. Should have separate dns node in /etc/map.publish for www domain.

3. Configure WWW and Non-WWW domains in a single virtual host:

In Virtual host:80 section,

ServerName  www.ourdoamain.com

ServerAlias ourdoamain.com

4. In rewrite section,

RewriteRule ^/$ https://%{SERVER_NAME}/<>.html [R=301,L]  ## landing page of the site - all the requests will be redirected to www domain .

RewriteRule ^/content/path/(.*)$ https://%{SERVER_NAME}/$1 [NE,L,R=301] ## content mask

RewriteRule ^/$ https://%{SERVER_NAME}/$1 [L,R=301]

5. Configure the similar rules in ssl.conf file with virtual host:443 

View solution in original post

2 Replies
Raja-kp
Correct answer by
Level 7
Level 7

Hi - @TB3dock ,

 

1.Should have proper SSL certificate for WWW domain.

2. Should have separate dns node in /etc/map.publish for www domain.

3. Configure WWW and Non-WWW domains in a single virtual host:

In Virtual host:80 section,

ServerName  www.ourdoamain.com

ServerAlias ourdoamain.com

4. In rewrite section,

RewriteRule ^/$ https://%{SERVER_NAME}/<>.html [R=301,L]  ## landing page of the site - all the requests will be redirected to www domain .

RewriteRule ^/content/path/(.*)$ https://%{SERVER_NAME}/$1 [NE,L,R=301] ## content mask

RewriteRule ^/$ https://%{SERVER_NAME}/$1 [L,R=301]

5. Configure the similar rules in ssl.conf file with virtual host:443 

bangar50
Level 7
Level 7

Hi @TB3dock ,

                     You can do it from etc/mapping  using sling redirect.

 

Kr,

Sanjay