RyanTAdams.com

Technology Advice by Ryan Taylor Adams

Changing the URL of Your WordPress Blog

May 16th, 2008 · No Comments · Printer Friendly Version

WARNING! THIS POST IS MORE THAN 180 DAYS OLD!

While I make an effort to update older posts to keep them relevant and technically accurate, the rapidly changing nature of the tech world makes it possible that the content of this post may no longer be relevant, current, or even accurate. Additionally, because of this post's age, adding new comments has been disabled. If you would like to contribute new information to this post, or have questions pertaining to this post, please use the Contact Form.


For the regular visitors here, you might have noticed that I have changed this blogs URL from //personal.ryantdams.com to //blog.ryantadams.com. Behind the scenes I also moved the actual WordPress files from a folder on my web server named “personal” to a folder named “blog” to better match the new URL. The big problem with changing the URL of my WordPress blog is making sure all the old links (either in my posts, or on external websites) still worked. Here is everything I did to move my blog to a new URL:

First, make a backup of both your database and the actual files in your WordPress folder. If something goes wrong, you’ll want these backups. Just in case you think, “Oh, nothing bad will happen…”, you should know that I had to restore from my backups five times before finally getting everything to work.

  1. Disable any plug-ins you have that even remotely depend on your blogs URL. For me, this meant disabling “Permalinks Moved Permanently” and “Hotlink Protection” along with several custom plug-ins I had made.
  2. Navigate to the Administration > Settings > General panel section of your blog.
  3. In the box for “WordPress address” change the data to your new blog address. BE CAREFUL TO TYPE IT COREECTLY.
  4. In the box for “Blog address” type your new blog address. Again, BE CAREFUL TO TYPE IT COREECTLY.
  5. Click “Save Changes” or “Update Options” depending on your version of WordPress.
  6. You will probably see a 404 error. This is OK. In fact, if you don’t see a 404 error you should be concerned. Just close down your browser and DO NOT attempt to access your blog at either it’s new or old address.
  7. Connect to your web server (presumably via FTP).
  8. Navigate to the folder containing your WordPress files, then delete the folder folder “wp-content/cache”.
  9. If you want to rename the folder your WordPress files are in, do this now.
  10. This step depends on how you have set up your URL and folders:
    • If you are using sub-domains or any form or redirection, log in to your web host’s control panel and be sure that the new URL for your blog (steps 3 & 4) points to the folder with your WordPress files (step 9). For example, I set the sub-domain “blog.ryantadams.com” to point redirect to the folder named “blog” on my web server.
    • If you are not using any sort of redirection, make sure the new URL for your blog (steps 3 & 4) accurately directs to the folder with your WordPress files (step 9). For example, if your new URL is “mysite.com/blog/wordpress/” your WordPress files should be in the folder “wordpress” inside of the folder “blog” located in the root of your web server.
  11. If you are using Permalinks, go to the Administration > Settings > Permalinks panel and click the “Save changes” or “Update Options” button.
  12. Finally, you will want to make sure that any links in your posts are updated to reflect the new URL. To do this, use PHPMyAdmin (which you should be able to access from your web host’s control panel) to run the following SQL Query:

    UPDATE wp_posts SET post_content = REPLACE (
    post_content,
    'old.mysite.com',
    'new.mysite.com');

    If you moved your WordPress fiels into a new folder, you will also want to ruin this query:

    UPDATE wp_postmeta SET meta_value = REPLACE (
    meta_value,
    'htdocs/personal',
    'htdocs/blog');

    Obviously, update the last two lines of each query with your own information.

  13. Now you can enable any of the plug-ins you disabled earlier.
  14. That should do it. One last thing you will want to do is set up some sort of redirection so that visitors who click links to your old URL will get to your new site.