Redirection rule from non-www to www | Adobe Higher Education
Skip to main content
Level 2
April 29, 2025
해결됨

Redirection rule from non-www to www

  • April 29, 2025
  • 7 답변들
  • 974 조회

Hi Team,

 

We received a customer request for redirecting a non-www to www

 

abc.com  (any page) should redirect (301) to www.abc.com

 

Can I have some suggestion for implementing this redirection rule. 

 

Thanks in advance!  

이 주제는 답변이 닫혔습니다.
최고의 답변: muskaanchandwani

Hello @anushaat 
If you are using AEMaaCS with OOTB Fastly CDN, you can utilize the Server-side Redirects in the CDN Configuration :
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/content-delivery/cdn-configuring-traffic#server-side-redirectors

Example -

kind: "CDN" version: "1" metadata: envTypes: ["prod", "dev"] data: redirects: rules: - name: redirect-non-www-to-www when: { reqProperty: host, equals: "abc.com" } action: type: redirect status: 301 location: https://www.abc.com{{ reqProperty: path }}

or you can handle the redirection at the Dispatcher Level :

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

7 답변

Level 4
April 29, 2025

Hi @anushaat ,

You can try adding the following rewrite rules to your dispatcher configuration:

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

This will redirect abc.com to www.abc.com.

 

Let me know if it works.
Thanks.

 

arunpatidar
Community Advisor
Community Advisor
April 29, 2025

Hi @anushaat 

Which CDN are you using? It will be easier/best practice to implement directly at CDN.

Arun Patidar
muskaanchandwani
Adobe Employee
Adobe Employee
April 29, 2025

Hello @anushaat 
If you are using AEMaaCS with OOTB Fastly CDN, you can utilize the Server-side Redirects in the CDN Configuration :
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/content-delivery/cdn-configuring-traffic#server-side-redirectors

Example -

kind: "CDN" version: "1" metadata: envTypes: ["prod", "dev"] data: redirects: rules: - name: redirect-non-www-to-www when: { reqProperty: host, equals: "abc.com" } action: type: redirect status: 301 location: https://www.abc.com{{ reqProperty: path }}

or you can handle the redirection at the Dispatcher Level :

RewriteCond %{HTTP_HOST} ^abc\.com$ [NC] RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L]
AmitVishwakarma
Community Advisor
Community Advisor
April 30, 2025

Hi @anushaat ,

Dispatcher (Apache) Redirect Rule

If you're using AEM Dispatcher (Apache HTTP Server), add the following to your dispatcher/src/conf.d/rewrites/rewrite.rules file:

# Redirect non-www to www (permanent 301) RewriteCond %{HTTP_HOST} ^abc\.com$ [NC] RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L]

AEM Cloud (Fastly CDN) Configuration

If you're on AEM as a Cloud Service, use Fastly Redirect Rules via CDN Configuration YAML:

kind: "CDN" version: "1" metadata: envTypes: ["prod", "stage"] data: redirects: rules: - name: redirect-non-www-to-www when: reqProperty: host equals: "abc.com" action: type: redirect status: 301 location: https://www.abc.com{{ reqProperty: path }}

Add this to your CDN Config repository (conf/cdn/redirects.yaml), and deploy via Cloud Manager pipeline.

Regards,
Amit

Adobe Employee
May 5, 2025

To implement a redirect from non-www to www (e.g. abc.com → www.abc.com), the industry-standard and most reliable approach in AMS/AEM environments is to use an Apache mod_rewrite rule at the Dispatcher (or web server) layer.

Example Rewrite Rule (Apache)

Add the following to your appropriate rewrite configuration file (commonly included in your vhost definition, e.g., /etc/httpd/conf.d/rewrites/base_rewrite.rules in AMS):

RewriteEngine On

# Redirect ONLY non-www to www for any page, preserving the path and query string
RewriteCond %{HTTP_HOST} ^abc\.com [NC]
RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L]
  • If you support both HTTP and HTTPS, ensure you listen on both ports, or adapt the rule to switch protocol as needed.
  • If your setup is behind a load balancer or CDN, you may need to consider whether the SSL termination happens before reaching Dispatcher.

Why do it at Dispatcher?

  • You have full control.
  • Changes can be made and tested by your team without waiting for AMS/CDN updates.
  • Consistent with best practices for maintainability and deployment simplicity.

Alternate or Complementary: DNS or CDN Redirection

Some teams also add redirects at the CDN layer (e.g., CloudFront, Akamai) or, in Azure, use the Application Gateway's redirect features, though this usually requires AMS or platform team involvement for changes and isn’t as self-service as the Dispatcher.


Best Practice:

  • Implement and test at Dispatcher.
  • Set up DNS for both abc.com and www.abc.com to point to your entry layer (CDN/LB/Dispatcher).
  • Ensure firewall/security group rules allow HTTP/HTTPS to the dispatcher.
  • Consider also redirecting HTTP to HTTPS inside the same rewrite ruleset if you want to enforce only secure traffic.
aanchal-sikka
Community Advisor
Community Advisor
May 5, 2025

@anushaat Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Aanchal Sikka
kautuk_sahni
Community Manager
Community Manager
June 27, 2025

@anushaat Just checking in — were you able to resolve your issue?
We’d love to hear how things worked out. If the suggestions above helped, marking a response as correct can guide others with similar questions. And if you found another solution, feel free to share it — your insights could really benefit the community. Thanks again for being part of the conversation!

Kautuk Sahni