Helpdesk
07.05.2025 09:06 22 Displayed

How to Add or Remove the WWW Prefix?

Today, many websites can operate with or without the www prefix (e.g., example.com).

In this article, we will explain step by step how to add and remove the www prefix.

For cPanel:

Adding www

One of the powerful tools used for URL redirection on Apache web servers is the .htaccess file. Now, let's address different cases:

For HTTP + www (If there's no SSL)

If your site doesn't have an SSL certificate (meaning https:// doesn't work) and you want it to appear only as http://www.example.com, add the following code to your .htaccess file to redirect only to www.

RewriteEngine On

# Redirect non-www HTTP requests to www HTTP

RewriteCond %{HTTP_HOST} ^example\.com$ [NC]

RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

For HTTPS + www (If SSL is available)

If your site has an SSL certificate (meaning https:// works) and you want it to appear only as https://www.example.com, add the following code to your .htaccess file to redirect only to www.

RewriteEngine On

# Enforce www and HTTPS redirection

RewriteCond %{HTTPS} off [OR]

RewriteCond %{HTTP_HOST} !^www\. [NC]

RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]

Important Note:

In the above code, replace example.com with your own domain name.

Removing www (For HTTP)

If you are not using an SSL certificate (i.e., only accessible via http:// protocol), add the following code to your .htaccess file to remove www from URLs that include it.

RewriteEngine On

# Redirect www HTTP requests to non-www HTTP

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]

RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Removing www (For HTTPS)

If your site has an SSL certificate (i.e., accessible via https://), add the following code to remove www from URLs that include it.

RewriteEngine On

# Redirect www HTTPS requests to non-www HTTPS

RewriteCond %{HTTPS} on

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]

RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

For Plesk:

1. Log in to Plesk

Log in to your Plesk panel.

2. Go to Websites & Domains

Click on the "Websites & Domains" tab in the left menu.

How to Add or Remove the WWW Prefix

Find the domain you want to work with from the listed domains.

3. Click on Hosting & DNS

Click on Hosting & DNS under your domain name.

How to Add or Remove the WWW Prefix

4. Click on Hosting

Finally, click on the Hosting option.

How to Add or Remove the WWW Prefix

5. Select Preferred Domain

You will see the following field on the page:

Preferred domain*

Select your preference and click the Save button.

  • www.example.com
  • example.com
  • None

How to Add or Remove the WWW Prefix

Congratulations! You've successfully added or removed the www prefix. You can check it by clearing your browser cache.

How to add the www prefix How to remove the www prefix How to add www How to remove www Adding www to a domain name