What is www?
A URL is your full website address. The part "www" at the front is a subdomain. A subdomain is a prefix added before your main name. So example.com and www.example.com are two different addresses. Both can show the same site.
It is best to pick one and send all visitors there. Search engines may think two addresses are two sites. A redirect fixes this. A redirect is a signpost that sends visitors from one address to another.
Step 1: check your DNS
DNS is the internet's phone book. Both versions must point to your site first.
- Log in to cPanel and open Zone Editor.
- Click Manage next to your domain.
- Make sure there is an A record for your domain.
- Make sure there is a record for
www. It can be a CNAME pointing to your main domain. A CNAME says "this name is another name for that one".
.htaccess file before editing it. A mistake can take your site down.Step 2: remove www (use the plain domain)
- Open File Manager in cPanel.
- Go to
public_html. Turn on Show Hidden Files in Settings if needed. - Open the
.htaccessfile with Edit. - Add these lines near the top. Use your real domain.
This sends anyone who types www to the plain address.RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ https://example.com/$1 [R=301,L] - Click Save Changes.
Step 3: add www (use www always)
- Open the
.htaccessfile as above. - Add these lines.
This sends anyone using the plain address to the www version.RewriteEngine On RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L] - Save the file.
WordPress sites
In WordPress, open Settings and then General. Set the WordPress Address and Site Address to the version you want. Save.
Test it
Open both versions in a browser. Both should end on the one you chose. If not, clear your browser cache or open a support ticket.
Quick recap
- www is a subdomain. The two addresses are different.
- Pick one version and redirect the other.
- Edit
.htaccessinpublic_htmlafter a backup. - Test both addresses.