You can configure your domain to automatically redirect between www and non-www versions, ensuring consistent access for your visitors.
Understanding www redirects
There are two main scenarios:
- Force www: Redirect example.com → www.example.com
- Remove www: Redirect www.example.com → example.com
Configuring www redirect in cPanel
Follow these steps to set up www redirects:
Step 1: Access Redirects
- Log in to your cPanel
- Navigate to the Domains section
- Click on Redirects
Step 2: Create redirect
- Select redirect type: Permanent (301)
- Choose your domain from the dropdown
- Configure the redirect based on your preference:
To force www (redirect to www version):
- From: example.com
- To: https://www.example.com
- Check Wild Card Redirect
To remove www (redirect to non-www version):
- From: www.example.com
- To: https://example.com
- Check Wild Card Redirect
Step 3: Apply settings
- Click Add to create the redirect
- Test the redirect by visiting both versions
Alternative method: .htaccess
You can also configure redirects using .htaccess file:
To force www:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
To remove www:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,L]
Best practices
- Choose one version: Consistently use either www or non-www
- Use 301 redirects: Permanent redirects preserve SEO value
- Update internal links: Use your preferred version in all internal links
- Set canonical URLs: Specify your preferred version in HTML
SEO considerations
- Avoid duplicate content: Redirects prevent search engines from seeing duplicate pages
- Preserve link juice: 301 redirects pass ranking power to the target URL
- Update Google Search Console: Add both versions and set preferred domain
- Consistency matters: Use the same version across all marketing materials
Testing your redirect
To verify your redirect works correctly:
- Open a web browser
- Type the version you're redirecting FROM
- Press Enter and check if it automatically redirects
- Use online tools to verify it's a 301 redirect
Important: Changes may take up to 24 hours to propagate fully. Test thoroughly before making the redirect live.
Tip: Choose your preferred version early and stick with it to avoid confusing search engines and users.