This article explains how to configure a redirect so that visitors who type "www." before your domain name are automatically sent to the root domain (the version without "www."). This ensures a consistent user experience and helps consolidate your site's authority.
Before you begin
You will need:
Access to your website's hosting control panel (such as cPanel or Windows Control Panel).
Access to your website's configuration files or a web server configuration tool.
Your domain name (e.g.,
example.com).
Configure the redirect via .htaccess
If your website is hosted on a Linux-based server using Apache (the standard for most cPanel accounts), you can use the .htaccess file to manage the redirect.
Log in to your hosting control panel.
Open the File Manager.
Navigate to the root directory of your website (usually
public_html).Locate the
.htaccessfile. If it does not exist, you may need to enable "Show Hidden Files" in your File Manager settings.Select the
.htaccessfile and click Edit.Add the following code to the top of the file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
7. Save the changes.
Configure the redirect via Windows Control Panel (IIS)
If your website is hosted on a Windows server using IIS, you can use the Web Redirect module or a rewrite rule.
Log in to the Windows Control Panel.
Select the domain you wish to modify.
Navigate to Web Redirect or the Rewrite section.
Create a new rule or edit the existing one to redirect
www.example.comtohttps://example.com.Ensure the redirect type is set to Permanent (301).
Save the settings.
Confirm the result
To verify that the redirect is working correctly:
Open a web browser and type
www.example.cominto the address bar.Press Enter.
The browser should automatically change the URL to
https://example.comand load the page.You can also use a tool like "Redirect Checker" to confirm that the server is sending a 301 Moved Permanently status code.
Limitations
DNS Propagation: While the redirect happens at the server level, changes to DNS records (if you are changing where the "www" record points) may take time to propagate across the internet.
Caching: Your browser may cache the previous redirect behavior. If the redirect does not appear to work immediately, clear your browser cache or test the URL in an Incognito/Private window.
SSL Certificates: Ensure your SSL certificate covers both the
wwwand non-wwwversions of your domain to avoid security warnings during the redirect process.
