How to Add WWW to a Website URL?

Trying to Add www to a website URL but don’t know how to proceed and what to do? Adding www prefix to a domain URL is a good SEO practice and you too can do it. It is quiet easy. Most of the websites owners in the word wide web add www to their website URLs. Also, it is found that there are some popular websites that get a lot of organic traffic yet they don’t add www to their website URL. So, whether to add www or not to a domain URL is a vital matter in the field of search engine optimisation(SEO).

How to Add WWW t o a website URL ?

Some readers also ask how to add www to a website URL. Adding www prefix to a domain will affect your site’s SEO? Can your site get millions of organic traffic if it does not add www to its domain? These are some of the questions that most of the readers ask about adding www prefix to a domain or website URL. In this tutorial I will explain all the facts so that you can solve such kind of issue for your site.

How to Add WWW to Your Website URL?

You can easily add ‘www’ to your website URL and it is easy. You are using wordpress. So, don’t worry. It has made everything easy. There are multiple ways to add www to a website URL or before domain name. Actually when you register a domain with a domain registrar, you do not add www before your domain name. You need to add www to your website URL when you create a new site. Follow the article till the end and you can add www to your site URL.

Add WWW to Your Website URL from Settings

Go to the Settings menu from your wp-admin dashboard. Click on Settings and it will be expanded as follows.

How to Add WWW to  a Website URL?

Now, you can see that the Settings menu contains several sub-menus such as general, writing, reading, discussion, media, permalink etc. We need to go to the ‘General’ sub-menu, as it contains site address and wordpress address of your website. So, click on the ‘General’ sub-menu and it opens a new page with the heading ‘General Settings’ at the top of it. Look below at the screenshot to have more instructions. It contains:

  • Site title
  • Tagline
  • WordPress Address(URL)
  • Site Address(URL) etc.

Keep in mind that you are going to add www to a website URL. And, whenever you click on the ‘General sub-menu, it will open the following page and you can see both the WordPress and Site address. As you have just started to make a new site on wordpress, it will not have www prefix to URL. So, before adding www to the website URL, look at the wordpress address and site address to be confirmed whether they contain HTTP protocol or HTTPS. Your site’s web address may contain either HTTP or HTTPS Protocol based on certain condition. If you have selected SSL when signed up to purchase a web hosting service, then automatically HTTPS will be added to your site’s web address, otherwise, it will add HTTP by default. If HTTPS is not added, then you can install and activate SSL Certificate and I recommend to activate it before adding www prefix to your website URL.

How to Add WWW to  a Website URL?

Now, go to WordPress Address(URL) and edit it based on whether you use HTTP or HTTPS. Add www after the double slash(//) and before the domain. If you use HTTP protocol, then type http://www.yoursite.com in the both field. On the other hand, if you have installed and activated TLS( SSL Cetificate), then type https://www.yoursite.com in the both field. Replace yoursite.com with your domain name. Once the entire process completed, scroll down and click on save to make your web address effective in the world wide web.

Add “WWW” to Your Website URL via WP-Config.PHP File

Also, you can add www to a website URL via wp-config.php File. To add www to your site URL go to the File Manager directly from your cPanel or via FTP. This method is recommended when you cannot edit your site URL from the ‘General Settings’ under the ‘Settings’ menu from your wp-admin area.

How to Add WWW to  a Website URL?

So, go to the File Manager from your cPanel and locate the public_html file. If you use Bluehost, then you can go to the cPanel from the the Advanced menu located along the left side of the wp-admin. Click on the ‘Advaned‘ menu. It takes you to the cPanel of your hosting service and it looks something like this.

How to Add WWW to  a Website URL?

Now, click on the File Manager and it will open the directory which contains various various files. Go to public_html and open it. Once it opened, you can see several files but you have to find out the wp-config.php.

How to Add WWW to  a Website URL?

Now, select the wp-config.php file and right- click on it. Once, you right-clicked on it, it will open several options like download, edit, copy, compress, view, delete etc.

How to Add WWW to  a Website URL?

Now, click on edit write the following lines of texts just above this line that says, ”That’s all, stop editing! Happy blogging”.

define (‘WP_HOME’ , ‘https://www.yoursite.com’); define (‘WP_SITEURL’ , ‘https://www.yoursite.com’);

Replace yoursite.com with your domain name.

Warning! Be careful when you are going to edit wp-config.php file and add the lines of texts mentioned above, because if you commit any error in adding the texts , it may result in wordpress errors. So, if needed , you can connect to your website using FTP client such as FileZilla, WinSCP etc.

Add WWW to Your Website URL via .htaccess File

You can add the www prefix to your website URL by using Apache rewrite rules in a custom .htaccess file. To perform this work, do the following actions one by one:

  • Head over to the File Manager from your hosting cPanel and open the File Manager.
  • Scroll down and locate the public_html directory.
  • Open the directory and locate the .htaccess file . Right-click on it and select edit.
  • Now, copy and paste the following lines of codes into .htaccess file.
   #Add www to any URLs that do not have them:  
  RewriteEngine on 
RewriteCond %{HTTP_HOST}!^WWW/. 
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]                                                                                                                                                                                   

Warning! Do not write RewriteEngine on more than one time if it is already present in the .htaccess file.

Once it is completed, save the .htaccess file. Now, you can check your web address on your browser to be confirmed about whether it shows www version of your site URL or not.

Add WWW to Your Website URL from Function.PHP File

You can add www to your website URL by editing the function.php file right from from your hosting cPanel>>file manager.

How to Add WWW to  a Website URL?

So, go to the File Manager from the cPanel of your hosting provider. Click on public_html and find out the function.php file. Once you have found that file, right-click on it and select edit. you can edit it in Notepad or Text Editor. Go to the end of the file and you can see all the codes written inside it. Now, you can add www to your website URL by adding the following two lines of texts at the end :

update_option(‘siteurl’ , ‘https://www.yoursite.com’); update_option(‘home’ , ‘https://www.yoursite.com’);

Replace yoursite.com with your own site address. Once these two lines of texts are added therein, click save and upload the file back to your hosting website. Also, you can use FTP to connect your site, edit the file and upload it back to your file manager.

Add WWW to Your Website URL from phpMyAdmin

You are using wordpress to build a website. It gives you a lot of options to manage your site—be it URL, navigation menu, logo, plugin, theme, category or anything else. In every field you get a lot of opportunities to manage your site. In addition to these four ways, mentioned above, you can use phpMyAdmin too to add www to your website URL. Using it you can access MySQL databases from your cPanel. To add www prefix to your website URL, head over to phpMyAdmin under the Databases section and click on it to launch it.

How to Add WWW to  a Website URL?

Once the app is launched, it will show you MySQL based databases which containing various tables and each one performs a certain type of function. Click on the databases located at left column with a prefix. In most cases, by default it includes wp_ database prefix. However, it may be variable from host to host. In the following screenshot it has GRM.

How to Add WWW to  a Website URL?

Now, click on the databases to make it expanded. When it shows the various tables, select the options table with database prefix and click on it. Once it opened, you can see the rows within it. Select the rows having the option_name : (1) Siteurl and (2) Home.

Now, you have to addd www to your siteurl. So, click on the pencil or Edit option located at the left of the row and you will see the following field. Now, write https://www.yoursite.com in the option_value field.

How to Add WWW to  a Website URL?

Similarly, click on the Edit button of the row that contains home as option_name and type https://www.yoursite.com in the option_value field.

Don’t forget to replace yoursite.com with your domain name. Once the entire process completed, scroll down and click save to make your change saved. Now, type your web address into browser’s tab and test whether it works properly or not.

Warning! Before doing this back up your wordpress databases and keep it stored somewhere so that you can use it to restore your site if anything goes wrong.