Moving a WordPress Site to a New Folder

media_1351024363365.png

Moving a WordPress site to a new folder is something you may need to do regularly.

The most common reason is that you’re launching a new site. In this tutorial, we”ll show potential problems during the move and how to overcome them.

Note: we’re not showing you how to move to a new server, simply to a new folder.

Step 1: Move the Files

The image below shows my WordPress site. Currently the site is happily sitting inside a folder called /oldlocation/ and it’s working perfectly.

media_1351024363365.png
  • Login to your site’s files via FTP.
  • Move all of your WordPress files from the old folder to the new folder.

media_1351026817420.png
  • Your site will now look like the image below. Almost everything will be broken.
  • In fact, you won’t even be able to login. If you try to access /new-location/wp-admin/, you’ll be redirected to /old-location/wp-admin/ and that will produce a 404 error.

media_1351024554937.png

Step 2: Change Site URLs

In order to regain access to your site, you first login to your site’s database. In this example, we’re using PHPMyAdmin which was provided by our hosting company.

  • Access your site’s database.
  • Look for the wp_options table.
  • Look for the siteurl row in the table. It will still contain your site’s old URL.

media_1351025224196.png
  • Edit that siteurl row.
  • Click Go to save the changes.

media_1351025275952.png
  • Now you can login to your site at the new URL
  • Go to Settings > General.
  • Make sure that both WordPress Address and Site Address are set to your new URL.
  • Click Save Changes.

media_1351025370429.png

Step 3: Fix the Permalinks

The .htaccess file that controls your site’s permalinks also contains your site’s URL. So, we need to fix your Permalinks.

  • Go to Settings > Permalinks.
  • Enter your URL choices.
  • Click Save Chnages.

media_1351026583089.png

Step 4: Fix the Images

  • When you visit your site now, everything should be working correctly, except for your images:

media_1351025559976.png

The reason for this is that WordPress actually hardcodes the URL of image into posts and pages.

media_1351025579907.png

You have two choices for fixing this:

  1. If you have a small site, you can change the image URLs manually.
  2. If you have a site of any real size, you’ll need to change the image URLs automatically. For this we recommend the Velvet Blues Update URLs plugin.
media_1351026015779.png
  • Install and Activate the Velvet Blues Update URLs plugin.
  • Go to Settings > Update URLs.
  • Enter your old URL and new URL.
  • Click Update URLs NOW.

media_1351026078593.png
  • Your images will now be fixed.
  • Your site move from the old folder to the new folder will be complete!

media_1351026151805.png

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

0 0 votes
Article Rating
Subscribe
Notify of
8 Comments
Oldest
Newest
Inline Feedbacks
View all comments
rahulr
rahulr
11 years ago

thank you for a great post. it seem very simple, I just wonder what will be the steps if one wish to test the new site before changing the DNS..

JUANDARUIZ 
JUANDARUIZ 
10 years ago

Great post! Thank you

Guest
Guest
10 years ago

This works great for all of the images.

Thanks!
But how do you get the old site to redirect to the new site?

[url=http://site.com/old-folder/same-existing-post/]site.com/old-folder/same-ex…[/url]

to redirect automatically to

[url=http://site.com/new-folder/same-existing-post/]site.com/new-folder/same-ex…[/url]
I am getting an error 404 endless loop.

Ari Anna
Ari Anna
8 years ago
Reply to  Guest

So what gives with the endless loop?

Fatman
Fatman
5 years ago

All worked fine but my wp-admin is broken. It displays all wrong. Any advice please?

Joeboy
Joeboy
3 years ago

Please can you guide me. I believe you have experience with linode.
I had issue with htaccess on my newly moved wordpress from shared hosting to linode.
Everything was working fine before but now my site is off as I rebuilt linode.
I will like you to guide me on how I can install wordpress again with one click installation without being asked to create another linode that will make me to pay.
Please help me. Thanks

Sakworaman Phokrai
Sakworaman Phokrai
3 years ago

Thanks a lot for the author. It works and solves my big problem. Love to tell and share this kindly attempt of yours. 

Preno JR
Preno JR
3 years ago

My website is broken few days ago because I transfer without knowing about this, after finding this tutorial on how to properly transfer a wordpress websites into another folder or domain within your hosting, now my website is working properly, all the images is perfectly correct and no broken links so far. I am planning on doing this and following the steps here for my other websites. Thanks again.

8
0
Would love your thoughts, please comment.x
()
x