How to Add or Remove the www Prefix? [cPanel and Plesk Guide]
14.05.2025 09:45 22 Displayed

How to Add or Remove the www Prefix? [cPanel and Plesk Guide]

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

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

Adding www for cPanel

.htaccess is a powerful tool used for URL redirections on Apache web servers. We will now cover different scenarios:

.htaccess for HTTP + www only (No SSL)

If your website does not have an SSL certificate (i.e., https:// does not work) and you want it to appear only as http://www.example.com, add the following code to your .htaccess file to force www.

RewriteEngine On

# Redirect HTTP requests without www to www version

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

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

.htaccess for HTTPS + www (If SSL is Available)

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

RewriteEngine On

# Force HTTPS and www redirection

RewriteCond %{HTTPS} off [OR]

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

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

Important Note:

Replace example.com with your actual domain in the code above.

Removing www (For HTTP)

If you're not using an SSL certificate (i.e., accessing via http:// only), add the following code to your .htaccess file to remove www from URLs.

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 website uses an SSL certificate (i.e., accessed via https://), add the following code to remove www from URLs.

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 control panel.

2. Go to the Websites & Domains Tab

From the left menu, click on the "Websites & Domains" tab.

How to Add or Remove www Prefix? [cPanel and Plesk Guide]

Find the domain name you want to manage from the listed domains.

3. Click on Hosting & DNS

Under your domain name, click on the Hosting & DNS option.

How to Add or Remove www Prefix? [cPanel and Plesk Guide]

4. Click on Hosting

Finally, click on the Hosting option.

How to Add or Remove www Prefix? [cPanel and Plesk Guide]

5. Select the Preferred Domain