Forwarding www.yourdomain.com to yourdomain.com from cPanel
To automatically redirect traffic from www.yourdomain.com
to yourdomain.com
, you can add the following code to your website’s .htaccess
file:
Instructions:
-
Access your hosting account's File Manager via cPanel or connect via FTP.
-
Locate the .htaccess file in the root directory of your website (usually
public_html
). -
Paste the above code at the top or appropriate section of the file.
-
Replace
yourdomain
andcom
with your actual domain name and extension.
Example:
If your domain is example.net
, the last two lines would be:
Why Combine www and non-www URLs?
Redirecting all traffic to a single URL version (either with or without "www") helps with:
-
Improved SEO & PageRank: Prevents search engines from treating
www
and non-www
versions as separate sites. -
Consolidated Traffic: All visitors are directed to a single domain version, avoiding traffic and link juice being split between URLs.