legacy-knowledge-base
公開されました Jun. 30, 2025

Redirecting a non-www Domain to a www Domain

投稿者

Jorge Diaz

knowledge-article-header-disclaimer-how-to

knowledge-article-header-disclaimer

legacy-article

learn-legacy-article-disclaimer-text

Issue

  • How can I redirect traffic from my non-www domain (e.g., example.com) to my www domain (e.g., www.example.com)?

Environment

  • Liferay DXP 7.4
  • Quarterly Releases

Resolution

You can configure a redirect using Liferay's pattern redirect feature:

  1. Access your website and navigate to Configuration > Site Settings > Site Configuration > Site URLs. Remove the non-www domain, keeping only the www domain. (e.g., www.example.com)
  2. reate a new site specifically for handling the redirect. In the Site URLs configuration for this new site, add the non-www domain. (e.g., example.com)
  3. In the new site, navigate to Configuration > Redirection > Patterns and add the following configuration:
    • Pattern: ^(.*)
    • Target URL: https://www.example.com/$0 (Replace example.com with your actual domain)
    • User Agent: all

This configuration redirects all traffic from the non-www domain to the corresponding URL on the www domain. For example, example.com/page will redirect to www.example.com/page.

Additional Information

  • This method uses 302 redirects, which can negatively impact SEO. For optimal SEO, configure 301 redirects at your web server level if possible.
  • See Using Pattern Redirects for more details.

 

did-this-article-resolve-your-issue

legacy-knowledge-base