Change non-www URL to www URL in WordPress

Today, I just changed the default URL of Hacker’s Lane from non-www version to www version, and now my blog’s URL feels better :)

I wanted to change it to as I thought that it would look more professional, I didn’t have any idea how to do it. After a bit of Googling I found a plugin to do that and the plugin didn’t work :(

Lastly,? got how simple it is, to change the default blog URL in WP. You don’t need any plugin or any other hack.


  1. Login to your WP Admin Panel.
  2. Go to “Settings->General”.
  3. On that page, change the “Blog address (URL)” to the www version of your blog’s URL. (See the pic below)

    Change non-www URL to www URL
    Change non-www URL to www URL

That’s it, now WordPress will redirect your non-www URL to the new www URL. But wait, we are not done yet.

SEO Requirement

We need to fix up some bits or your posts would have duplicates in index of search engines. To do this, we would use 301 permanent redirect on our old non-www URLs so that the search engines would index only the updated WWW version of your site.

For this,

  1. Edit the .htaccess file located in the root of your server, or the htdocs/public_html folder.
  2. Add this lines to your .htaccess:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^
    RewriteRule (.*)$1 [R=301,L]
  3. Save it and you’re done. :D

11 Replies to “Change non-www URL to www URL in WordPress”

  1. Hi,very very thanks for the solution…….i didnt know that it was so easy…..Will it change the indexed url in google to new one?

    1. Hi,

      Google would index your new URLs automatically the next time it crawls your site, but you are supposed to redirect your old URLs to the new one or your posts will be having two URLs in Google Index.

      I’ve added the SEO Requirement, please follow it.

      Thanks. :)

      1. Hi,thanks for the update…but i followed a different method(please tell me if it doesnt work)-
        After changing non-www to www url in WP,i went to webmaster tools and added both urls(non-www and www) and then in settings of www url,i changed preferred domain as http://www.url..
        Will this work without any problem?

        1. Hi,
          Even after setting up the preferred URL in Google Webmasters, most of the listings will have both of your URLs as two DIFFERENT sites and hence will penalize your rankings for duplicate content. Google Webmasters will only help you with Google rankings, think about the rest. And yes, I have read many cases in which the site’s rankings were badly hit due to two URLs. I strongly recommend you to redirect non-www site of yours to www, that would prevent any SEO damage to your site. :)

          Google says the same:

          Note: Once you’ve set your preferred domain, you may want to use a 301 redirect to redirect traffic from your non-preferred domain, so that other search engines and visitors know which version you prefer.

  2. Hi,

    Thanks for solution with SEO !!!!

    But I got your blog after 4-5 weeks of non-www to www redirection by just changing in wordpress general setting but not done changes in .htaccess and now I got search penalty by Google now can you suggest what to do ?

  3. Hi I have been trying in vain to add these lines to the .htaccess file with no luck.

    The current .htaccess file reads:

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    # END WordPress

    Your help would be very much appreciated. nB

Leave a Reply

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