The site has a www and a non www version. We only want to keep the www version. Can this be done with AEM? | Community
Skip to main content
December 26, 2018
Question

The site has a www and a non www version. We only want to keep the www version. Can this be done with AEM?

  • December 26, 2018
  • 3 replies
  • 1879 views

So the site recently shifted on AEM and underwent a full transformation. However, we realized that www and non www version of the site exists and we only wish to keep the www version. How to fix this in AEM?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

arunpatidar
Community Advisor
Community Advisor
December 26, 2018

I think, it can be fixed at Network layer or dispatcher or at server by redirecting all non www request to www

Arun Patidar
edubey
Level 10
December 26, 2018

You can configure rewrite rule at apache for this. If urls are not complicated, a generic should be able to take care of all. You can keep your aem free from all this task.

Rule will append www to incoming request,

Gaurav-Behl
Level 10
December 26, 2018

There are multiple solutions to achieve this:

1) Apply an irule to redirect all non-www requests to www at external Load-balancer used of your site. E.g. BIGIP  // At times it can be performance intensive based on the volume of traffic

2) Depending on the physical architecture of your site and if you have a multi-domain site pointing to same origin server, then you may use another solution at DNS level. //this solution depends on how DNS setup is done.

3) Apply the redirect at apache or use CQ rewrite rules aka mappings.  // Not recommended because this would still serve the cached content to non-www requests from CDN/dispatcher and would not enforce redirection at all times. Could become performance bottleneck or a design issue in the future based on your requirements

If you have a simple use case then go with Load balancer irule something like --

irule:

when HTTP_REQUEST {

        HTTP::respond 301 Location "https://www.[HTTP::host][HTTP::uri]"

  }

CQ mapping rule for reference: