How to Move Your WordPress Blog from a Subdirectroy to Root

Sun, Aug 16, 2009

Moving WordPress

Always be sure to fully back up your blog before attempting a move.

Many times, new bloggers might put their blog in a subdirectory, like /blog or they did not realize that when you install WordPress manually, it will be installed in the /wordpress directory. If this is the case and you want to move your blog out of a subdirectory and into the root folder of your site (i.e. you domain name), then follow the instructions in the video below.

If you have any questions, please comment below.

, ,
John's Wishlist

83 Responses to “How to Move Your WordPress Blog from a Subdirectroy to Root”

  1. Deborah Says:

    Hi
    This video was great! And I almost got there. But when I tried to import the new database I got the message “Can’t create new database – database exists”. But I did drop the old database and it is empty. So I am totally stumped and now don’t know what to do. Please help.

  2. John Hoff Says:

    Hi Deborah. Make sure you’re using the “Import” tab up at the top in the phpMyAdmin area. You want to import the newly edited database and not “create” a new one.

    Let me know if that helped?

  3. peluang bisnis Says:

    Thanks for sharing good information, i learn how to move wordpress here.

    Keep posting.

    David

  4. John Hoff Says:

    Hi peluang, no problem. I’m glad you found the tutorial useful. I have a few more videos in queue as we speak.

  5. Adrienne Says:

    Thank you, thank you, thank you! I was almost in tears trying to transfer a WordPress Site in a subdirectory over to the root directory. I was going through the data base by hand, trying to make changes, installing new applications of WP into the root and trying to transfer data and a bunch of other round-about processes and was just pulling my hair out (and did I mention the tears?). Then I found your site!!! It was a life saver…and the process is soooo easy (made even nicer by your lovely manner of speaking and that wonderful drawl…). Who would have thought…. Anyhow, I have a number of WP sites in subdirectories that I’m working on…afraid to put them in the root for fear of losing all my hard work but now I know how! Thank you so much. I plan to cruise your site some more (once my adrenalin subsides) for nuggets of knowledge. I am donating a little something to you once I finish this (lengthy) note…it’ll buy you a cup of coffee and a doughnut – probably not the new equipment but I’m a starving blogger/web designer/horse owner (and God do they tap your wallet) at the moment (I can send you a horse….).
    Adrienne

  6. John Hoff Says:

    Hi Adrienne.

    Glad we could help. We’re here to help everyone learn and make their lives just a little bit easier – we believe in good karma around here (plus we learn a lot, too)!

    Thanks so much for the donation. One latte and coffee cake coming right up!

  7. Brian Says:

    This is very neat tutorial but it won’t fix the SEO issue where you have backlinks to posts in your old blog. If you don’t fix the permalink issues, you will lose all the link love from your old blog.

    I am guessing there needs to be a 301 redirect step somewhere to make this complete.

  8. John Hoff Says:

    Hi Brian, thanks for stopping by and leaving a comment. Congrats by the way on the newborn. I have 2 boys of my own – 1.5 and 3 years old.

    To answer your .htaccess question, I have used this code in my “test” blog which worked for fixing broken links when moving my blog from the root to a subdirectory. It might work the other way around, too.

    I’ll admit though, it’s been awhile since I toyed with it.

    Redirect 301 ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/([a-z0-9\-/]+) http://yourblog.com/blog/$1

    You can try removing the /blog part in the url and seeing if that works. If it’s something you really need to know, let me know and I can try testing it out.

  9. Josh Says:

    Hello, nice tutorial. Only thing is, and this might be what Brian was talking about, after I move my blog over, none of the pages link anymore. That is to say, if I try and visit any of the pages other then the main page in my blog, they are all “not found” What’s going on with this? It’s driving me crazy! I can’t find any thing on the net that fixes this. Your tutorial was very clear. thanks.

  10. John Hoff Says:

    Josh, did you try the .htaccess redirect from my last comment?

  11. Josh Says:

    It was the permalinks. I originally had them set to something other then default when I moved the site. I went into settings and went to permalinks, set them to default and saved changes, and when I tested, the links worked again. I was then able to set it back to the way I had it before the move and it all still works. hotdog! I don’t know if its a bug or if its suposed to work like that, but there it is. I was using 2.9.
    Thanks again!

  12. Josh Says:

    no, I’m a bit new at this and didn’t know what that was, but that permalink thing seemed to work… thanks. :)

  13. Nithiyaah Says:

    Hi John,
    Great video tutorial. But, I’ve two questions here. First,my permalinks are not working properly and second how to get those valuable backlinks again. You have mentioned about redirecting again. But, for a beginner like me won’t understand it in mere words. Can you explain it in another video tutorial like the above. I also moved my blog from my subdirectory to the root directory. It’ll be nice if you can visit my blog and leave some comments about it. Thank you.

  14. John Hoff Says:

    Hi Nithiyaah. I just visited your blog and the permalink structure seems to be working fine. Did you get that sorted out.

    Like what Josh had to do, many times you just need to reset them in your Settings -> Permalinks area.

    I’ll see about doing up a video soon. Right now I’m about to launch a new product and it might be a few days.

    For now, you might want to try the WordPress support forums on that redirect error.

  15. Nithiyaah Says:

    Hi John,
    Thanks for the comment. What I don’t get it here is how to redirect my old link to to my new site. I just was playing with the permalinks & it falls in the right place. My old link was http://nithiyaah.com/blog and the new one is http://nithiyaah.com. But, the problem is I’m getting some traffic from other’s blogs where I used my previous link and please tell me how to fix this problem. I’ll wait for your reply and it will be great if you can show this thing in a video. Sorry for troubling you alot while you are super busy with your new product creation. Thanks in advance and good luck with your product creation.

  16. John Hoff Says:

    Hi Nithiyaah. Got it. Ok, here’s what you want to do…

    If you log into your web hosting control panel and go to your File Manager area, you should see a file named, .htaccess.

    Open that file and scroll down to the bottom and add this line of code:


    # Redirect http://nithiyaah.com/blog to http://nithiyaah.com
    redirect 301 /blog http://nithiyaah.com

    The line with the # in front of it is just a comment line, so you can change the wording if you want. The next line is the one that does the redirect. 301 is telling search engines that this is a permanent change and to please start indexing this page instead of the /blog.

    That takes care of your home page, but you might still have issues for links pointing to all your posts because those links probably had /blog inside of it.

    You can either try this first and see if it works…

    Add this line of code just below the redirect you did above:

    Redirect 301 ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/([a-z0-9\-/]+) http://nithiyaah.com/blog/$1

    or…

    For each one of your blog articles, set up a 301 redirect like you did for your /blog.

    So for example, it might look like this:

    redirect 301 /blog/2010/02/19/why-im-not-into-video-blogging/ http://nithiyaah.com/2010/02/19/why-im-not-into-video-blogging/

    Do this for each of your articles.

    Sorry, I can’t make a video right at the moment, I’m not in the right setting (cartoons & kids in the background), but if you’re having troubles figuring it out, let me know and I’ll try and do a video either tonight or tomorrow.

  17. Jordon Wong Says:

    John,
    Thank you so much for the video. It has truly helped me to get my blog up and running. You’re the Bomb!

    Jordon

  18. John Hoff Says:

    My pleasure, Jordon.

    Oh man… just checked out your blog, you’re from Hawaii! I’m so jealous.

  19. Nithiyaah Says:

    Hi John,thanks for the advice and I’m trying to work on it. But, still got some problems & currently I’m facing a new problem that is eventhough I have moved my site to the root directory, but it seems like certain files have not been moved to my root directory. I’m really clueless what to do next :-( I recently try to post an article with the relevant images.But, the images are not showing in my post and they are still in my old directory,the blog. What am I supposed to do now? Any help is highly appreciated and I’m truly sorry for all th trouble John.

  20. John Hoff Says:

    Maybe check your image upload settings. Go to Dashboard | Settings | Miscellaneous area and make sure you have the correct path set up for the uploads.

    If that doesn’t work, I assume you’ve moved all your actual WordPress files, but maybe what you need to do is export your database to your computer, do a find/replace of all your old domain.com/blog links to your domain.com address.

    If you try that, please make a backup first.

    If you’re not sure about it all, it might be best to hire someone to fix the issue for you. You don’t want to lose anything because of inexperience.

  21. BigBear19460 Says:

    Thanks. Great video

  22. John Hoff Says:

    Hy BigBear. No problem and thanks!

  23. Amega Says:

    Great video. I am going to be setting up a new blog and don’t want people to access it from root yet, this will help me build on a sub-directory. Thanks.

  24. John Hoff Says:

    My pleasure, Amega. Good luck and thanks for the comment.

  25. Ryan Says:

    Hi John,
    Great tutorial…I followed all the steps but for some reason my homepage works but none of the links to any of the pages or posts work…I get the error like this:

    The requested URL /category/videos/ was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

    Any help would be greatly appreciated….when I log into the site it doesn’t take me to the dashboard either it goes to a index page with links to:

    Index of /wp-admin

    * Parent Directory
    * admin-ajax.php
    * admin-footer.php
    * admin-functions.php
    * admin-header.php
    * admin-post.php
    * admin.php
    * async-upload.php
    * categories.php
    * comment.php
    * css/
    * custom-header.php
    * edit-attachment-rows.php
    * edit-category-form.php
    * edit-comments.php
    * edit-form-advanced.php
    * edit-form-comment.php
    * edit-link-categories.php
    * edit-link-category-form.php
    * edit-link-form.php
    * edit-page-form.php
    * edit-pages.php
    * edit-post-rows.php
    * edit-tag-form.php
    * edit-tags.php
    * edit.php
    * export.php
    * gears-manifest.php
    * images/
    * import/

  26. John Hoff Says:

    Hi Ryan, just visited your site. Looks like you got it fixed?

    Also, hey I love surfing! Nice site.

    Just FYI the problem was probably because your database contained links pointing to the old link / directory structure. You’d want to download your database and find and replace those old links with the new structure.

    I think that’s right at about 5 minutes into the video.

  27. Jon Osmond Says:

    Thank you for creating this video! Very well-done.

  28. Caroline Says:

    Hello,

    Thank you so much for your video tutorials, they have really helped me a lot!

    I just finished the above process, but I’ve done something wrong and I am terribly frustrated at this point.

    I am able to log in to WP through the site http://rentaladvisors.com, instead of /wordpress. Everything works fine in the backoffice.

    However, my web-page is completely blank! I had an index.htm file, but it is renamed and moved. All wordpress files are in my root directory, although Im afraid maybe not all are copied, but my /wordpress file was blank. I have no .htaccess file and index.php was not the original index file.

    Should I just restore my backup and start over?
    Im obviously a newbie, but the site was running perfectly before and now I have a huge blank page.

    Thanks for the help,
    Caroline

  29. John Hoff Says:

    Hi Caroline.

    Did you by chance make the change of url in your database or in your Dashboard | Settings area? That sounds like it could be the issue.

  30. Caroline Says:

    Hi,

    Thanks for your very quick response! I really appreciate your help.

    Well, I changed that when we did the find & replace, so when I logged in the back office, the Dashboard-Settings already had the URI in place.

    Caroline

  31. Caroline Says:

    John,

    Just wanted to say thanks again for all your help.
    I used one of your other videos to create and customize the home page.php (too bad you cant see right now!)

    I think I may have messed up the file transfer (step 1); just don’t understand how the back-office works perfectly and the page doesn’t show…

    If I don’t figure it out in the morning, I will probably restore the backup and start the process in the video again; probably the safest & easiest thing to do at this point. Hopefully will have everything working then, we have a deadline of June 1.

    I will definitely let you know the results. I’m sure the process you’ve demonstrated is correct, as I’ve done much research and see this is the best way to go about it.

    Your videos are GREAT, kudos to you. Many thanks again!

    Hasta pronto
    Caroline

    PS, are you from the South? Im from Texas and appreciate a nice southern accent, especially being over-seas. cheers :)

  32. John Hoff Says:

    Hi Caroline, actually this video was created by one of my colleagues here. If you click to some of the other videos and hear another voice talking, that’s me. The gentlemen in the video’s name is Steve and yes, he’s gotten lots of compliments on his voice hehe.

    Something must have messed up somewhere. It is odd that the backend is working fine but the front is not. Really without more information on each step that was done it would be hard to figure it out from my end.

    Try again tomorrow and if you run into any issues, let me know. Also, make sure to have a backup of your backup. Always better to be extra safe.

  33. Caroline Says:

    Hi John

    Sorry for the mistake. But still thanks for the great site and support.

    It turns out that bottom line– Yahoo server hosting is bad. They wont let you move WP to the root; the site just wont work. After much frustration, problems with the database and Yahoo confusion, we are moving the blog to a new server.

    I found a great free-lance web developer to help figure out the problem and he is in the process of moving the site now. I am grateful and lucky to have found him on a beautiful Saturday to save us from this mess.

    Im sure if it weren’t for our server troubles this process would have gone smoothly. Thanks for all the help and have a great weekend!

    Caroline

    PS: Thank goodness for the backups! and backup backups! Thank you!!

  34. John Hoff Says:

    My pleasure Caroline. Don’t forget we offer WordPress blog hosting as well… and all the videos are tailored to our services.

    Good luck and chat with you later.

  35. @FasTake Says:

    Thanks! Superb! WordPress codex itself explained it backwards

  36. Kathy Pop Says:

    Thank you for making that video. I had tried other methods, but either some of the directions were unclear or just didn’t work.

    One other step that I had to do was to go to my permalinks settings and save (didn’t have to change anything) I also had a page that came up to update my DB.

    Your method made it a breeze and now I’m ready to tackle some others.

    Kathy Pop

  37. Sacramento Wedding Photographer Says:

    WHEW!!! Your video is an absolute lifesaver. I followed the directions and it worked perfectly. I had some serious doubts because I have a ton of Themes and Plugins installed, and some pretty heavy customization of various PHP files. Without this video, I wouldn’t have had the confidence to try this.

  38. John Hoff Says:

    @FasTake, Kathy, and Sacramento….

    Thanks guys, I’m glad it worked out for you.

  39. Bob Says:

    The video was very helpful. I did get the following error on importing:
    “#1007 – Can’t create database ‘xxx’; database exists”
    So the fix was to remove the CREATE DATABASE command from the import file. Then everything worked just fine. You have a great site, keep up the good work!

  40. John Hoff Says:

    Hi Bob. That’s odd, but hey… at least we got it, right?

    Thanks for leaving a comment and have a great day.

  41. John Says:

    thanks for the great tutorial. One question, when I look at my exported .sql file, I’ve got a lot of interesting paths, ie:

    [quote]
    :”/hermes/bosweb/web208/b2089/ipw.goraider/baby/wp-content
    [/quote]

    these seem to be primarily for plugins(?)
    I’m not sure what to dowith them. I’m hesitant to openly post my direct path but would be glad to share off-line.

    Any thoughts help much appreciated.

    …John

  42. John Hoff Says:

    Hi John. To be honest I’m not a database expert and I wouldn’t want to advise you on anything relating to your database outside of what I am familiar with.

    My suggestion would be to post in the WP support forums and ask your question there.

  43. Martin Says:

    Hi John,

    Brilliant, a truly fantastic tutorial that even a newbie could follow without being drowned in techno-speak; short, direct and to the point – well done. I managed to move my site from a subfolder to the root (www.eartheartom.com) with the minimum of hassle and stress by following step by step what you said – and I’m really not that technical at all!

    Just for your information, I had some html in a text widget in one of the sidebars (to enable a lightbox effect to display a couple of images) which didn’t transfer across, it just vanished! But I figured it must be in there somewhere, so with the new found confidence from your tutorial I managed to find it by doing a search in the localhost sql document (I could remember the name of an image in the html) where I copied it out, tidied it up a bit, and it works!

    Great work, thanks again

    Martin

  44. John Hoff Says:

    Hi Martin. Glad it worked and I was able to help. Video is awesome, isn’t it?

    Congrats.

  45. Jim Zook Says:

    John,

    Thanks for making a great tutorial. It worked perfectly.

    Your instructions are clear, well paced and simple to follow. I am more or less a WP newbie so I am grateful.

    Best to you,

    Jim

  46. John Hoff Says:

    Hi Jim,

    Sure not problem, thanks for the comment.

    Since you’re new to blogging, I have a new membership site I’m about to launch which will showcase a TON of videos on learning how to use WordPress, blogging tips, making money online, SEO, etc.

    It’ll probably be somewhere around $17 a month. Would you want me to put your name on the contact list to notify when the site is finished?

    Thanks again,
    John

  47. VesicP Says:

    Awesome vid! I am almost there but have an issue. It is not pulling up, or showing, the photos from the them or from the galleries. I followed the vid and made all the changes to the sql, and even tried some of the WP plugins to fix links, but no luck. My site is at http://www.vesic.com.
    Any ideas?
    Thanks,

  48. John Hoff Says:

    Hi VesicP. Hmm… not sure. It seems to always work for me. It would be something I’d have to toy with to figure out. If it’s something you’re really wanting to do, it might be worth paying an expert to do it for you. Shouldn’t be too expensive.

  49. Ray Colon Says:

    Hi John,

    Thank you for these tutorials. The ones that I have viewed today are very well done. I’m hoping that you can help me with a slightly different issue.

    I have a traditional website on the top level domain and my blog is in the /blog subdirectory. What I would like to do is: move my WordPress admin to the top level. Once there, I plan to manually convert my existing site into pages within WordPress. The results that I seek are:

    - future blog posts to continue to be published in the /blog subdirectory;
    - Pages that I add to WP to replicate my website can be added to their current subdirectories.

    My thinking is that this will maintain all of my existing search engine links to both my website and my blog, while enabling me to manage both within WordPress.

    Is this doable?

    Thanks, Ray

  50. John Hoff Says:

    Hi Ray, yes it’s doable; however, if you’re a newbie to doing this sort of work I’d highly suggest doing one of two things.

    Either:

    A) Duplicate your entire site on another domain and set it up in the robots.txt file so you block search engines from accessing the site (that way you don’t confuse Google with two duplicate sites and content). Then use that site as your entire testing ground for figuring it out.

    B) I would suggest you pay someone to do the work for you. It will be done much faster and you’re going to save yourself a TON of headache. When you start doing that level of work to your blog, it’s well worth a small investment.

    Of course never do ANYTHING without a full back up of your site. Both files and database.


Trackbacks/Pingbacks

  1. [...] How to Move Your WordPress Blog from a Subdirectroy to Root [...]

  2. [...] NewsPlant these Companions with Tomatoes – Modern Survival Blog – surviving uncertain timesVideo: How to Move WordPress from a Subdirectroy to Root var ajax = new Array(); function TrackClick(link,title) { var index = ajax.length; ajax[index] = [...]

Leave a Reply