Move Wordpress Blog from Subfolder to Root folder

If you are looking to move your wordpress blog from some subfolder say /blog/ to Home Root folder, there here is the step by step guide to do it -

1. We are going to assume that your current wordpress installation is in /blog folder. Though not really required I will still advice you to take backup of your full /blog folder in case you delete something by mistake it will help you to get it back immediately.

2. Now copy all the files of /blog folder into / folder. Make sure you copy .htaccess file too. Also you should not have any index.php and index.html file in root folder.

3. Open wp-config.php file of root folder and add this line

define('RELOCATE',true);

after define statements. Save it and upload it back onto server in root folder.

4. Open page http://example.com/wp-login.php (type your domain name instead of example.com) and enter your admin login details.

5. Go to General Settings and make sure in WordPress address (URL) field, you have http://www.example.com (i.e. your domain name) and remove anything from Blog address (URL) field i.e. make it blank. Most likely it will be having http://example.com/blog in it. Also make sure you don’t leave trailing slash “/” in domain name.

6. Check .htaccess file of your root directory and make its content like this

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

That is it. Your wordpress blog is moved to Root Home folder / from subdirectory /blog folder

7. Finally again open wp-config.php and remove

define('RELOCATE',true);

line and save it back.

This is all you need to move your wordpress blog. Most of the steps are self explainatory. We moved the blog files from sub folder to root folder so paths of upload files remains same and your blog keep showing all images.

The 3rd step was done to overwrite wordpress blog url so you can login into wordpress from url http://example.com/wp-login.php otherwise it would had taken you to http://example.com/blog/wp-login.php. After that we logged into wordpress and changed the default wordpress installation directory to be root /.

After this you can delete /blog folder or can keep it for some time but block the path /blog/ using robots.txt so search engines don’t crawl the pages of /blog folder causing duplication.

If you are still having difficulties in moving wordpress blog, you can ask me in comments.

Related posts:

  1. Images not showing in wordpress blog Many times when you change your host (or server)...
  2. Know 3 Hidden and Less Used Wordpress Features I have already covered lot of wordpress related content in...
  3. Reset Wordpress Password using PhpMyAdmin and Mysql Today somehow MWolk Blog which runs on wordpress stopped accepting...
  4. Show Post Edit Link on Wordpress Blog Posts Most of the wordpress themes by default comes with this...
  5. Get Tree like Drop Down Menu Navigation in Wordpress blog Wordpress has this awesome plugin (well most of them all...


Liked this post ? Subscribe to MWolk Blog via RSS Feed or via Email and receive free daily Tech and Money making tips.

28 Responses to “Move Wordpress Blog from Subfolder to Root folder”

  1. 1Edward Barnard on May 22, 2009 :

    I just tried your tip and it looks like it worked perfectly. Thank you!

    I took over webmaster duties, tried to set everything up in Joomla, and decided I’m not doing anyone any favors by using Joomla. (Prohibitive learning curve if I hand duties over to someone else in future.) Back to wordpress. I installed wordpress in a subfolder, copied each article one by one to wordpress, and just now shoved joomla off to the side. Looks like moving the wordpress install to the root folder worked perfectly.

  2. 2Rich N Fit Life on May 24, 2009 :

    Thanks for this wonderful help.

    I did exactly as you said…and I was very much successful in moving my blog to root directory. But I still have to change internal urls for links and images within the posts… manually :( Any solution for that?

    Rich N Fit Life’s last blog post..Simple steps to help you prevent emotional eating!

  3. 3Abhimanyu on May 24, 2009 :

    You had used relative or absolute paths for images ? If you have moved the site properly, it should not require to change any paths. Does the root folder has the .htaccess file ?

  4. 4lostasylum on Jun 22, 2009 :

    i’m having the same problem as “Rich N Fit Life”.. (you can check out my website.. it’s still like that)…..

    managed to change my blog to the root directory, but all the URLs and images don’t appear because it’s still linking to the old address…

  5. 5lostasylum on Jun 23, 2009 :

    i’ve managed to solve my problem with the images!!!

    thanks so much to a good friend and WP guru moses for providing me with the life saving article.. also, many thanks to the writer of this article….

    http://wptoy.com/tips-tricks/fix-missing-images-during-wordpress-database-import/

    hope this will help many others…

  6. 6Drew on Jun 27, 2009 :

    HI - followed your instructions everything went fine - can access admin just fine but when i try to view public site I get, access forbidden error.

    Any suggestions?

  7. 7Dotty on Sep 30, 2009 :

    I currently have a website with a blog attached in a folder. I am looking to combine the website and blog and use WP to manage the whole site. I will be trying the method described above. Before doing this I would like to know how to change or reroute the existing url’s. For example I have the url for my portfolio (http://premiumwebsites.net/webportfolio.shtml) at many locations throught the Internet. I could not possibly ever get them all changed by going to all locations (cant remember them all). How can I make sure that incoming links will still work?

  8. 8Abhimanyu on Oct 1, 2009 :

    from .htaccess, do a 301 redirect for old urls like example.com/webportfolion.html to example.com/webportfolio (this is wordpress url)

    You will get all link juice with 301 redirect

  9. 9gevenia on Jan 28, 2010 :

    hi there , please i’ve followed the instruction up to the 4th step - when i tried login in from http://example.com/wp-login.php , its just come out as blank page ,

    i’ve not deleted my site in the subfolder so when i tried to log in from the subfolder, ie. http://example.com/blog/wp-login.php, its going back to http://example.com/wp-login.php and again showing blank page.

    the site itself is fine, but i dont know how to log in to the admin page now

  10. 10Mark on Mar 16, 2010 :

    Thank you so much! This really saved my day. After getting erroer after error because I moved my content without thinking of these few steps ….

    Cheers from Norway

  11. 11Hillary on Jul 7, 2010 :

    You rock! This works perfectly. I’ve used your method several times now and it works like a charm every time. THANK YOU!

  12. 12Mom-E on Jul 12, 2010 :

    Thank you! This post was exactly what I needed! I too ran into issues with images not showing up, but it had to do with the permissions on my cache folder for thumbnails. (In my case, this directory is located in the root directory for my theme and is called cache…If others have this issue…)

    Thank you again!

  13. 13Alexfs on Sep 11, 2010 :

    your post helped me so much - i am extremely grateful to you - i was struggling to get the wordpress from the subfolder to the root for quite a while - your post is so simple and so easy to understand
    thank you very much!

  14. 14JS on Nov 4, 2010 :

    so I just realized that I forgot to take step 7 when I transferred a whole bunch of sites. But no problems have arisen since.

    What’s the risk if I leave it in there?

    I’m hoping I don’t have to go back to all the sites I built and figure out which ones have it and which do not. Please advise. Thanks.

  15. 15Graham Armfield on Nov 4, 2010 :

    Thanks for this really helpful post. It enabled me to migrate my Wordpress installation to the root directory without any issues really.

  16. 16Stefan on Nov 30, 2010 :

    I haven’t tried your tipps yet but I have to move one of my blogs from folder to root soon. Which rewrite rule will redirect my then outdated google search results links beginning with “foldername/” to the new links without “foldername/” in it?

  17. 17Coi Mattison on Dec 1, 2010 :

    I lost all my files so I re-uploaded my backup folder which has a different name. When I go to upload its saying “Unable to create directory /chroot/home/xxx/domain.com/html/wp-content/uploads/2010/11. Is its parent directory writable by the server?”, plus all of my picture and sound links that were already there, say “file not found”? What can I do?

  18. 18Iros on Dec 19, 2010 :

    I’ve had the same problem as ‘gevenia’ , in that I want to have wordpress in my subdirectory to serve as a development location, and then have the main site in the root.

    Whenever I try to log in to the subdirectory’s wordpress (i.e. http://domainname.com/beta/wp-admin/) I get redirected to the live admin…

    And also, when I go to the root of the development location I get a not found error (i.e. http://domainname.com/beta/ ) ..gives me not found. I am sure it has something to do with .htaccess . Any help please!!!?

  19. 19Iros on Dec 22, 2010 :

    There are some tricks to perform with .htaccess that can do this, but my .htaccess skills are not up to par.

    I think the best answer to this problem is to download Wordpress 3, or Wordpress MU, and set up a multisite. This will allow you to have sites in the main directory and in any subdirectories you desire… and it takes care of the .htaccess settings for you!! This is what I did, and it solved my problem, and can probably help Gevenia with hers as well.

  20. 20Chandramouli on Jan 1, 2011 :

    Hey,
    Thanks for the tip. Great help!

  21. 21Jameson on Feb 3, 2011 :

    I am about to try this move, but two things concern me:

    My images are linked via WP default upload. Will the .htaccess file ensure the links are refreshed? i.e. /wp-content/uploads/image instead of /blog/wp-content/uploads/image? Is that what .htaccess does?

    Also, is there a solution for the wp-admin blank page result people have been having trouble with? Any recommendations before I try would be much appreciated. Thanks!

  22. 22maria on Feb 5, 2011 :

    how to do it with wordpress 3.0.4 multiblog?
    there is no wordpress adress in setings>>general…

  23. 23ranjith on Mar 8, 2011 :

    i did the same but my links are not working can u pls..help me anyone?

  24. 24Jameson on Mar 13, 2011 :

    Just a few more notes regarding this process.
    I just did it successfully, but here were my challenges: (Currently using Wordpress 3.1)
    I copied my files up to the root folder and everything checked out until I tried logging in. I had to log back into the /blog/wp-admin folder and then change both the Wordpress AND Site address to be my root domain. Wordpress updates have not allowed for a blank Site address as is suggested in step 5. So make sure the two are the same.
    Then I was allowed to login from domain.com/wp-admin.
    At this point, you virtually have two working sites: domain.com and domain.com/blog
    I went ahead and deleted my /blog folder via FTP at the end of the process, and any links to images and links to various places on your site that YOU have entered, i.e. - Single images for blog posts, header logos, links to pages from inside posts, etc. very well may become unlinked. IF this is the case, I’m not sure what to do. My blog is fairly limited in this type of content, so I was able to swiftly go though and re-link everything by deleting the /blog in each instance. I don’t recommend this, and take this as a word of caution, especially if you have a large blog with a lot of images/etc.
    Other than that, it looks as though someone posted a link above that might work as a walkthrough in that regard.

  25. 25Martin on Apr 1, 2011 :

    I’m using wp 3.0.3
    I am trying to do what you posted but in reverse, moving from root folder to a subfolder instead of a subfolder to root. Moreover, the subfolder was also created in the root folder on a different server. I copied the database and all files and folders including hidden files. The main page is displaying fine but all the links to other pages are not working, where the browser is saying missing link.

    In Settings–>Permalinks I am using Custom Structure using this /%category%/%postname%/ which is not working but if I change to the Default option everything works.
    I have been trying to put my subfolder name as myFolderName/%category%/%postname%/ but it does not work.

    What do I need to do to make this work?

    Thank for any help

    /M

  26. 26Kevin on Apr 16, 2011 :

    Thanks, this worked like a charm. It took awhile to update some image links but everything is working fine now.

  27. 27rodo on May 11, 2011 :

    Hi, i cant fint de .htaccsess file Where is it? What if it´s not there??
    Thanks

  28. 28Rahul Parekh on Jun 10, 2011 :

    Just tested this on my local server. Works like a charm! Thanks a lot.

    Also you may like to mention that this method can be used to change sub folders, too (for absolute beginners).

Leave a Reply

Name Email Website URI