How to Move WordPress from a Subfolder to the Root Directory

Many people like to create and test a new version of their site in a subfolder so that it does not affect their main domain. Once completed, they will want to migrate the new site over to the root directory for the domain. This is very common with WordPress. Follow the instructions below as we guide you on how to move WordPress from a Subfolder to the Root Directory.

Make a Backup of your account

Before performing the following procedure, it is a good idea to make a backup of your account prior to making any changes. Learn how to make a backup here: Backup website files in cPanel.

Prepare your WordPress installation for the move

Prior to physically moving the files, you will need to prepare the installation to accept the new URL name.

  1. Log into your WordPress Dashboard. For example.
  2. From the main dashboard, go to Administration -> Settings -> General.
  3. Next, look for the WordPress address (URI): and change it from (example.com/WordPress to example.com)
  4. Lastly, look for the Site Address address (URL): and change it from (example.com/WordPress to example.com)

Moving your WordPress from a subfolder to your main folder

After you have made your backup, removed the site files from the builder, and prepared your WordPress files, it is time to move your WordPress to the primary folder.

  1. Log into your cPanel admin dashboard.
  2. From the main cPanel area, look for the Files category and then click on the File Manager tool. Go to Settings In the Preferences window that appears, select the checkbox entitled Show Hidden Files.
  3. Once inside the File Manager, you will want to navigate to the folder you have the WordPress site in. For example, a folder named WordPress.
  4. You will see a list of all the WordPress files and folders in the right hand panel. Highlight them all and click on the Copy icon from the menu toolbar across the top of the page.
  5. A popup will appear so you can enter the destination folder. Continuing with our WordPress folder example, it should show as public_html/WordPress. Remove the /WordPress from the destination path so that it simply displays as public_html. Click the Copy Files button.
  6. This will copy the files up to the public_html folder. Use the File Manager to navigate back to the public_html folder. (You can do this by clicking on the Up One Level button from the toolbar across the top of the right hand panel.)
  7. You should now see the same files as you have in your WordPress folder.
  8. You can now delete the old WordPress folder.

Log in and finish the URL details

  1. Log into your NEW WordPress admin dashboard. For example (example.com/wp-admin or example.com/wp-login.php)
  2. Go to Administration -> Settings -> Permalinks and ensure the link structure is the same as your new URL.

Are you interested in unleashing the power of WordPress? Our managed platform for WordPress is fine-tuned to deliver superior performance, security, and provide best-in-class hosting. Be sure to check out our WordPress-optimized hosting plans.

Thoughts on “How to Move WordPress from a Subfolder to the Root Directory

  • Hello,

    It’s Very usefull to me as I was looking for some tricks to transfer files to the root directory. Searched so many blogs but you guys are amazing on this job, and usally I don’t leave a comment but your article is so good and helpfull that I thought and writing this.

    Again thanks for the simple trick, as I’m not going to use Duplicator plugin no more.

    All the best!

  • Follow the tutorial step by step and now I have the error message ‘ 

    Briefly unavailable for scheduled maintenance. Check back in a minute.’ on my wordpress site which I was intending to switch to. 

    How do I  fix this?

    • We would need more information to help you. Please provide details on the issue and we can try to help. You can also contact our live tech support team (contact info at the bottom of the page).

  • After i have update the wordpress and site URL, how can i go back and reverse it?

    Also, i find something strange is that when i entered the URL, xxxx.com then it redirect to xxxx.com/subdirectory and i manually delete the subdirectory then it’s fine, is there anything or configuration in c-panel that i need to update?

    Also, i do not know what is wrong on the mobile.

    Thanks.

    • You would need to change the settings again with the updated URL to revert it back. We do not block mobile traffic explicitly, so I’m not sure why your phone would not see the site. Can you describe what you’re doing on your phone that is different from the computer? Note that WP does have a default area in the .htaccess file. If changes are made there or re-direct changes are applied above their code OR if another .htaccess file has precedence over the one for your WP site, then it can affect the behavior of the website. Also, if you make changes to the .htaccess file of your WP site then you should always make sure to clear the browser cache before trying to re-load the site in that internet browser.

  • Hi,

    My url with the sub folder still shows up after i have moved all the files. Also, the site don’t appear in the mobile phone anymore.

    How do i resolve that?

    Thanks.

    • Ensure you have updated your “WordPress address (URL)” and “Site Address address (URL)” as described in the first section above. Also, test with another browser or clear your browser cache before testing.

      Thank you,
      John-Paul

  • I just wanted to let you know that I just did this and it worked beautifully!! Thank you – such a relief. The only hitches I had was links to some media files like pdf or video or audio files which I had to update. But overall, everything moved over like a dream. Thank you!

  • After doing the above steps, I get the error when I want to access any page

    You don’t have permission to access /test2/index.php on this server.
    Server unable to read htaccess file, denying access to be safe

     

    Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

    • I recommend checking your .htaccess files stored on your server, as the error indicates that is the cause of the issue. However, since it does not specify the location of that file, you should check all the .htaccess files.

  • after doing all steps my wp admin deshboard is open but when i click site they show me your website is under construction how can i fix that?

    • It sounds like you may have an under construction plugin enabled or an index.html file your browser is defaulting to in your document root, i would recommend disabling any underconstruction plugins and removing any excess index files.

  • Hello! I have a main domain in my root folder and an addon domain (unrelated to the main domain) as a subfolder in the root. I made a dev subfolder in the addon domain, which is located as another subfolder in the root, alongside the addon itself. I want to move my dev subfolder to the root and delete the addon domain.

    Do I need to take any extra steps in this situation? Will the files for the main domain interfere with the dev subfolder once I move it to the root?

    Thanks so much in advance.

     

    • Hello Mila,

      Thanks for the question about moving the dev folder. As long as it’s in the folder, there should be no interference with the other files. You will need to make sure that you change the root location for the subdomain if you have defined it as a subdomain in the cPanel. If not, then you don’t have to worry about it. If you have configurations which rely on the location of the dev folder then you may need to change the location of the folder.

      I hope this helps to answer your question, please let us know if you require any further assistance.

      Regards,
      Arnel C.

    • Hello Mila,

      Thanks for the question about moving your dev folder. No extra steps are necessary. As long as the files remain in the folder then they shouldn’t interfere with anything else. Of course, there shouldn’t be a duplicate of the dev folder – otherwise, you’ll have a naming issue. If you have any configurations relying on the location of the dev folder then you will need to change the location to match where you have moved it.

      I hope this helps to answer your question, please let us know if you require any further assistance.

      Regards,
      Arnel C.

    • Hello Aya,

      If you have hard links in a post or page, then you would need to update them. However, anything new will NOT have the subdirectory included in the path. After you have made the change, make sure that you are updating the permalinks in your WordPress installation.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  • Hi,

    I’m about to move my new WP website to the root and delete my current website, but I have a question. In my current .htaccess file I have a long list of redirects and this code:

     

    options +SymLinksIfOwnerMatch

    RewriteEngine on

    RewriteCond %{HTTP_REFERER} !^$

    RewriteCond %{HTTP_REFERER} !^http://(www\.)?example.*(/)?.*$ [NC]

    RewriteRule .*\.(avi|gif|jpg|jpeg|bmp)$ http://www.example.*/ [R,NC]

     

    Options +FollowSymlinks

    RewriteEngine on

    rewritecond %{http_host} !^www\.example\.nl [nc]

    rewriterule ^(.*)$ http://www\.example\.nl/$1 [r=301,nc]

     

    (I have changed the name of my domain to ‘example’).

     

    Now, in the current WordPress directory there is also a .htaccess file, which contains:

    # BEGIN WordPress

    <IfModule mod_rewrite.c>

    RewriteEngine On

    RewriteBase /wordpress/

    RewriteRule ^index\.php$ – [L]

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule . /wordpress/index.php [L]

    </IfModule>

    # END WordPress

     

    Do I need to combine the two or is the WordPress htaccess code redundant once I moved the WP website to the root?

  • Create a file named index.php in your domain root with the following content….

     

    define(‘WP_USE_THEMES’, true);

    require(‘./Mainsite_New/wp-blog-header.php’);

     

    Where Mainsite_New is your WordPress site folder name.

     

    Enjoy!

     

    RDS

  •  Great tutorial – worked like a dream. I usually use Duplicator, which is free and also goo but this method is the easiest and fastest I;ve come across.

    Thanks John-Paul! 🙂

  • hi, want to ask

    if i wanna change my wordpress from blog.domain.com to domain.com/blog in iis with vb.net, is possible or not ?

    anybody have a solution for this ?

    thanks before

    • The intro page may be index.htm or index.html and your first page is index.php. If that is the case, rename the index.htm or html page. This should allow the index.php page to show for your site.

  • Don’t know if this impacts anybody (perhaps a note in the installation directions) but when I did the conversion try as I might I couldn’t get the wordpress changes to appear.

    It suddenly occurred to me that my existing site uses index.htm andthe wordpress uses index.php.  After renaming my existing index.htm Firefox now brings up my wordpress site. 

     

    Mark

  • Hi , I’m haveing a problem i’m using the web.com cpanel and i can’t get the files to the root and even i tried installing the wordpress direct to the root but it want let me , I tryed even serching on youtube but on web.com nobody has a video ( and web.com support want help me ) so what shoud i do ? i even tried on filezila and it want let me in 

    • Unfortunately, it is difficult to say since I do not know the access levels of their setup. I do know on our servers, you have access to your files via cPanel File Manager, or FTP.

      Thank you,
      John-Paul

  • Hi.

    I have moved my files from /dev/ to live but the ‘Home’ link on my navigation bar still goes to the dev site. The other links work okay.

    Any ideas what is wrong?

    Thanks

    Stephen

    • Make sure to check if the Site and Home URL were updated after the move. You can add change this setting in the WordPress General Settings, as mentioned above in the section headed “Prepare your WordPress installation for the move”. You can also add set the Site and Home URL in the wp-config.php file to get the same effect.

    • Hello karim,

      Thank you for contacting us. I checked the link you provided, and am just getting a “page does not exist” message.

      Is that the error you are getting?

      If not, can you provide the full error message?

      Best Regards,
      John-Paul

  • I am not real fluent on c_Panel or the organization of things so not sure I am following what you are suggesting.  If I follow all the steps in this article down to step 8 and don’t delete subfolder, are you saying I can’t use it as I am now as a development area?  Are you saying instead that I should create another directory  and move the  the WordPress subfolder content to this directory.   Isn’t the subfolder a database.  It shows as a database in c_Panel.  What is in my subfolder is not a subdomain so should I be creating a subdomain and coping my database to there?  

    Thanks

    • Hello Ken S.

      Sorry for the confusion. First, your database is NOT in a folder on your website. It’s in a separate location on the server. WordPress references the database in wp-config.php. If you have ALL of the necessary files for running WordPress in a subfolder, then you can use that site as long as there is a separate database setup for that site. I test all the time using WordPress subdomain installations. As long as you have all the necessary elements for the WordPress installation to work (the WordPress core files, a wordpress database, and a properly configured wp-config.php file), then it shouldn’t be a problem to use the site as a test site. It doesn’t hurt to have another WordPress site for testing, but it’s not always necessary either. It will be up to your needs. If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  • After coping Wordpress from a subfolder to root is it OK to leave the WordPress subfolder with the original WordPress files and use it as a test or development site?   Will it cause any issues.

    • Moving a WordPress installation to a different location on your server can definitely cause the site to function differently. However, copying can be harmless if the content is copied to a different directory. If you’re going to use the copied files as your testing site make sure you create a database and database user with the appropriate privileges.

  • My WordPress Settings/General do not have the WordPress Address and Site Address fields – neither editable nor non-editabe. I tried to definte these variables by hand in the wp-config.php file, but I still get the WP install prefix the same as before. Why would these fields be missing, and how can I reconfigure WP so that it looks in public_html folder, rather than public_html/wp?

    Thank you!

    • Hello Colin,

      Sorry for the problem with the WordPress and Site address fields. If you’re not seeing the Address and site address fields in General, then it may be either theme or plugin related. Make sure you’re using the latest version of WP, and then make sure to use the default theme and no plugins. If you continue to have the same problem,then I would recommend re-installing WordPress. We would need more information about your installation – URL, version of WP, custom theme/plugins and also the steps (or URL) to see the problem you’re having.

      I hope this helps to answer your question, please let us know if you require any further assistance.

      Regards,
      Arnel C.

  • Hi TJ, Thanks for your response. I did look at the error logs – they say there was a fatal php error on line 80 of my config.php. I am hosting on another server and followed your directions thinking they would work. Not sure how I would see anything wrong on my .htaccess file or on my index.php. Hosting service has been asked to restore files and server to before I attempted the move but it seems like they either don’t understand what I’m asking or don’t know how to do it or aren’t able. I’m sure if I knew just a little more I could untangle this mess!

  • I (thought) I followed these instructions but am getting a 500 Internal Server Error when I try to go to the site and a 403 Forbidden error when I try to log into the dashboard. Don’t know where to begin!

    • Hello John,

      Are you able to see the apache logs? This would provide you with the direct issue regarding the 500 error. Generally the issue comes to either file permissions or something wrong in your .htaccess file.

      Best Regards,
      TJ Edens

  • Hi and thanks for the tutorial…

    unfortunately although i followed all the instructions my website is still not showing up. I copied all the files that were in my Test folder into the root (public_html)… after that i checked to see if my site was working, instead i only had a blank page appear… 

    i then accesed my db via phpadmin and exported my db, replaced all the urls from mydomain.com/test to mydomain.com , imported the new db after dropping all the tables first.

    and still same result.

    I should mention that oddly enough my domain.com/test is still loading properly :-/

    what am i missing here?

    Thank you in advance!

    • Hello Mark,

      Have you tried reverting your theme back to the default 2014 theme? This is usually the cause for blank wordpress installations.

      Best Regards,
      TJ Edens

  • Hi Scott, Im not sure what I did, however I seem to have managed to get it to upload properly using your previous comments this time (very strange). So sorry for sending the original query. Thank you for your past help, the tutorial is great to follow.

  • Hi Scott. I fixed the last problem I had importing the sql back, however this time nothing seems to fix it and I am freaking out as I need to get the site up and running today :-/

    Im not sure if its the theme that I have used that may be causing the problem.

    Can let me know what I am doing wrong please…

    SQL query:

     


    — Dumping data for table `wp_commentmeta`

    INSERT INTO `wp_commentmeta` ( `meta_id` , `comment_id` , `meta_key` , `meta_value` )
    VALUES ( 1, 1, ‘_wp_trash_meta_status’, ‘post-trashed’ ) , ( 2, 1, ‘_wp_trash_meta_time’, ‘1430279887’ ) ;

     

    MySQL said:

    #1062 - Duplicate entry '1' for key 'PRIMARY'

  • I recently moved my WP site from a subdomain/folder to the root. Now I’m wondering how to fix all the old broken links that I previously shared on my social media pages to (at the very least) redirect to my homepage. Thoughts? Thanks.

    • Hello Hodgie,

      This is due to having data already in the database with that ID. When you export the database, set the Insert Ignore option. This will then add rows even if their ID exists. However it will delete the current ID and give it the next available one in line.

      Kindest Regards,
      Scott M

    • Hello Don,

      Sorry to hear you’re having problems with saving your theme. Can you tell us if you’re a customer? And if so, can you please provide the account information? It sounds like a permissions issue, but we can’t what the problem is without looking at the account.

      If you have any further questions or comments, please let us know.

      Regards,
      Arnel C.

  • OK. Here is MY problem. I did everything EXCEPT delete the DEV folder (/test) The index page comes up. But when i click on another link OR try to Login, I get this:


    Fatal error: Cannot redeclare jetpack_is_mobile() (previously declared in /home2/seamona/public_html/test/wp-content/plugins/jetpack/class.jetpack-user-agent.php:3) in /home2/seamona/public_html/wp-content/plugins/jetpack/class.jetpack-user-agent.php on line 59

     

    Please help!!Everything is Broken now and I cant get it back!!

    • Hi,
      I’m not really ease with wp, it’s new for me. A quick question for you. I’m just starting the process and first problem when I tried to change the WordPress address (URI) and the Site Address address (URL). My adresses are example.com/test and not example.com/wordpress. I deleted /test at the end of both and when I saved, I received an error message:
      Not Found

      The requested URL /wp-login.php 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 idea to help me? Thanks a lot!!

    • Hello Melanie2496,

      Thanks for the question. Actually, the error is normal. You’re just missing some of the steps required to finish that change. The link following the SITE URL option goes to this tutorial: Giving WordPress Its Own Directory. If you follow the steps here, then it will work properly. Sorry, it’s not too obvious in the Administrator – it’s something that I wish WordPress would fix myself.

      I hope this helps to answer your question, please let us know if you require any further assistance.

      Regards,
      Arnel C.

    • Hi Arnel,
      I ignored the error and continued the steps, but now seems to be worst…
      The current website doesn’t work, all my folders of wp are writing on the page:
      Index of /

      license.txt
      readme.html
      wp-activate.php
      wp-blog-header.php
      wp-comments-post.php
      wp-config-sample.php
      wp-config.php
      wp-cron.php
      wp-links-opml.php
      wp-load.php
      wp-login.php
      wp-mail.php
      wp-settings.php
      wp-signup.php
      wp-trackback.php
      xmlrpc.php

      When I try to go on the administration of the new website, I have this error message:
      Not Found

      The requested URL /wp-admin was not found on this server.

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

      In cpanel (File manager) the former files have been replaced by the new from wordpress but when I go to my FTP nothing changed. Any idea?

    • Hello Melanie2496,

      It is difficult to determine what you’ve done based on what you’re showing me. If you are an InMotion Hosting customer, can you please provide your domain name. We can look at the account then help you resolve issue you’re facing. If you’re not a customer of InMotion, then we need to go BACK and look at the steps provided in the WordPress Codec to determine where things went wrong.

      Please give us a little information so that we can provide further assistance for this issue.

      Regards,
      Arnel C.

    • Hello Melanie,

      Your best bet is probably simply to reset, remove all of the current files and then re-install WordPress. Otherwise, you will need to backtrack and undo what you’ve just done. Get back to the point where all you did was change the Site URL. Once you have done that then you can refer back to WordPress’s directions. I think that there was some misunderstanding with the directions starting at step 7.

      Regards,
      Arnel C.

    • Hello Shimanto,

      I am not understanding what you are asking. Could you please respond with what it is you want to do step by step if possible?

      Kindest Regards,
      Scott M

    • Hello PaulaC,

      To remove the builder files, you would simply delete them manually from within the cPanel file manager.

      Kindest Regards,
      Scott M

  • I am not sure if I am missing a step in moving my WP files from a sub-directory in the root directory. There is a sentence that says removed the site files from the builder. How is this done? Currently I am at the step of backing up the files. I have not changed the URI or URL names yet

  • Thanx, Very Helpful Article , Everything is perfect after moving my site to the main root according to the article instructions.

  • hi

    i’ve completed everything fine till step 8 and my website is live showing all the wordpress stuff

    but the next step where you said login to your new wordpress dashboard

    example.com or example.com/wp-admin that is giving error

    • Hello Syed,

      Sorry for the problems with the WordPress move. In order for us to help you, we need more information, please. If you can provide a URL that we could check, it would help us understand what’s happening. It also helps to know if you’re using any re-directs, plugins, or directory changes that may have affected the location of the WordPress Administrator. If you’re not sure, then you may need to troubleshoot the WordPress plugins, or check the WordPress database for the setting used for the WordPress Administrator.

      Please provide us a little more information and we can investigate the issue further.

      Kindest regards,
      Arnel C.

  • Nice guide, i moved my site from folder to root, but now no mails sent from wp. Post notifications, registration mails, lost password mail, doesn’t send at all. Any idea?

  • Folks …
    Great info, moved without a glitch from subfolder to main domain > www.*****.cn

    Did what I needed – thanks again

     

  • I followed this tutorial and the WP site is coming up fine, and can log in like normal so all is well EXCEPT the theme colors and background has changed back to default. So that didnt “move” with everything or something changed it.

    I still have the subfolder with good design – but I cant log into that anymore either.

    How do I get the theme, custom css, colors, skin to move to the root directory ?

    Thanks!

    Paul

    • Hey Paul,

      Were you sure to copy everything from your /public_html/wordpress directory to just /public_html?

      It also sounds like you could need to change the WordPress URL of your site if you forgot to change it prior to copying your WordPress site from a sub-folder to the root of your site.

      A quick way to check is to place this highlighted code in your wp-config.php file:

      define(‘WP_HOME’,’http://example.com’);
      define(‘WP_SITEURL’,’http://example.com’);

      // ** MySQL settings – You can get this info from your web host ** //

      That should force things to load from the proper URL, as it’s usually a bad link to a CSS stylesheet that causes display issues after moving. If that fixes it, follow the other steps from that guide to make it permanent and remove the settings from your wp-config.php file.

      If that’s not the problem, you might also have issues with content directly stored in the WordPress database using the sub-folder URL. In phpMyAdmin you could simply click on the Search tab and look for subfolder-name with at least one of the words and clicking on Select All and then Go.

      Please let us know if none of that does the trick for you.

      – Jacob

    • perfect. saved my life. perhaps explain how to do it with Filezilla rather than c-panel. Just found it a little easier to do it this way.

    • Hello Ahsan,

      Do you have specific images that you are referring to? The images that I checked on your site have paths starting from the home directory.

      Kindest Regards,
      Scott M

  • Hi,

    This a very useful article/tutorial, but I guess that there are other alternatives to the “manual” migration process.

    I’ve seen several plugins like Duplicator that can help you migrate from server to server.

    I’ve also developed another plugin for this, it’s a complete solution:

    http://codecanyon.net/item/wp-golive/7793291?ref=RedhopIT

    GoLive plugin has a lot of features:

    Automatically Export the Database from Source Server
    Transfering the files via FTP automatically
    Auto-import Database in Remote/destination server.
    Update .Htaccess properly
    Update wp-config.php file on destination server with the new credentials.
    Replace the URLs in Database (Posts, Pages, Menus…), and keep auto-update serialized objects too.

    I hope it helps someone.

     

    Regards,

  • Just another reason that WordPress sucks badly. The other one WP being totally incapable of doing complete exports with images, templates and everything. With this much software bloat, why couldn’t anybody make WP easily movable, backupable and restorable?

    • Most CMSs, such as WordPress, Joomla, and Drupal will define your URL within it. This causes the additional changes to be made and is not something that is specific to WordPress.

Leave a Reply