Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to Add or Remove www from Your Website Address

This guide shows how to make your site open with www, or without it, and keep just one version.

Domains and DNS2 min read12 steps

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.

  1. Log in to cPanel and open Zone Editor.
  2. Click Manage next to your domain.
  3. Make sure there is an A record for your domain.
  4. 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".
Warning: Take a backup of your .htaccess file before editing it. A mistake can take your site down.

Step 2: remove www (use the plain domain)

  1. Open File Manager in cPanel.
  2. Go to public_html. Turn on Show Hidden Files in Settings if needed.
  3. Open the .htaccess file with Edit.
  4. Add these lines near the top. Use your real domain.
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
    RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
    This sends anyone who types www to the plain address.
  5. Click Save Changes.

Step 3: add www (use www always)

  1. Open the .htaccess file as above.
  2. Add these lines.
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
    This sends anyone using the plain address to the www version.
  3. 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 .htaccess in public_html after a backup.
  • Test both addresses.