How To Remove “www.” From a WordPress Site URL

At one point, I wanted to remove all references to www. that appears before the domain name in the address bar for hosted Wordpress websites.

I didn’t want to use plugins and so I went through all the files and databases related to the WordPress installation to make the changes manually.

I wrote down what I did and it should work for you.

The instructions:

  1. In WordPress admin, go to Settings > General and, if it exists, remove the “www.” part of the address in the WordPress Address (URL) and also in the Site Address (URL) (e.g. replace “” with “”.
  2. Export an SQL dump that has the DROP TABLES IF EXISTS and CREATE TABLES commands for the MySQL tables that runs the WordPress site.
  3. Make a backup of this SQL dump if you need to revert back to it and use a working version of the file to make changes.
  4. In your preferred text editor open the working version of the SQL dump and replace all instances of the URL with “http://” followed by “www.” with the same text  without the “www.” part (e.g. replace “” with “”).
  5. Next replace all instances of “” with “”. This will remove the “www.” part in links within content.
  6. If the path to your server root directory uses the “www.” part of the URL, then the replacement in point 5 above will have made your server root address incorrect and this will need to be corrected. Your server root directory can be found by creating a PHP file with the code below, FTPing it to your server root and then accessing it using your browser. For example if you create a PHP file called server-root.php with the code below then in your browser enter it’s URL (e.g.

    The browser should display the server root directory: (e.g. “/home/myserver/1234/”).
    If the domain part of the server root directory has the “www.” in it like the example above then the replacement in point 5 above will have to be put back as follows, otherwise you can skip this step.In your working version of the SQL dump, replace all instances of (for example) “/home/myserver/1234/” with “/home/myserver/1234/” (simply putting the “www.” back into the server root path).

  7. Save the changes in the working version of the SQL dump and import it into the WordPress site’s MySQL database.

The above instructions should remove the www. from the address bar.

Now test your WordPress site without the “www.” and also test the links throughout the template and content.

If there are any issues then import the backed up version of the MySQL dump and you should be back where you started.

Share this:

Subscribe for updates

Enter your email address below. I’ll send you updates & news to your email address. You can unsubscribe at any time.





Leave a Reply

Your email address will not be published. Required fields are marked *