Website Addresses With and Without WWW

By default, hosting accounts are set up so that website addresses with the prefix "www." are also accessible and are aliases of website addresses without www. Example: your domain is, so by default also points to (the content is the same if accessed). You can simply upload the file once to either one, as they are both the same, and will be accessible with and without www.

But there are times when people want a website address without www to be inaccessible. This desire is actually unreasonable, because there is no harm in making it easier for visitors to type in the website address with or without www. Most websites also allow us to access them with or without www (eg:,,, etc).

But if you want to try this setting, here's how. There are two alternatives that you can try:

Table of Contents

Alternative 1

When visitors type in a website address without www, for example, it really doesn't find its IP address. The browser will display an error message such as "hostname not found" or "Cannot find website address."

To perform a setting like this, you need to delete the A record of (or, in your case, the actual primary domain).

1. login to the control panel, choose Manage DNS

2. Click the DNS Manager menu, click Edit Zone

3. then delete the A record for, then click Done.

Screenshot from 2019 06 26 22 11 49 My CMS

Caution: do not delete any other records, such as the MX record for, as this means that the email address will not work. Here's a picture of the DNS manager that you need to change.

Alternative 2

The second alternative, which is more user-friendly and preferable to the first method, is that when visitors type in an address without www, e.g., they will be automatically redirected to, so that the address visible in the browser's address bar is the one with www.

Things needed

Before following this tutorial, make sure your domain is configured to be accessible with or without "www" via the "Advanced Zone Editor" menu in your cPanel.

Make sure you find the following configuration:

1. So that your domain is always redirected with www then please add the following script in your htaccess file:


RewriteEngine on

RewriteCond %{HTTP_HOST} ^ [NC]

RewriteRule ^(.*)$$1 [L,R=301,NC]

Noted : change with your own domain name.

2. Conversely, if you want your domain to always or only be accessible without using "www", and if anyone accesses it using "www" it will be redirected to without "www" then you can add the following script in your htaccess configuration:

RewriteEngine on

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

RewriteRule ^(.*)$$1 [L,R=301]

Noted : change the section with your own domain name.

Configure URL with or without www for Wordpress users

For those of you who use Wordpress Hosting, it will be easier to configure the switch if done from within your own Wordpress Dashboard. so you don't have to bother changing the configuration in the htaccess file.

  • Please login to your wordpress dashboard page and on the sidebar select the Settings > General menu, then fill in your domain in the column marked with an arrow.

How to Create .htaccess Files on cPanel


  • Please login to your cPanel page, search and find the File manager menu.

  • search and find the public_html folder, please enter the folder and click on it so you can see the files inside. 


  • Next, please create a new file by clicking the "File" menu then name it ".htaccess". so the file name begins with a period. 


  • To enter data in it, simply select the file and click the "Edit" menu.

  • there are times when the htaccess file is not visible or hidden, and to display it just click the 'Settings' menu at the top of the


  • Then put a check mark on the : Show Hidden Files (dotfiles) and click "Save".


  • This is what the .htaccess file looks like in your file manager

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.