Moving a site from subfolder to top level

I'm finishing up a redesign of a company site. The company's current site (non wordpress) is still active and the new site is in a subfolder. So basically, I need to move the new WordPress site from to with little to no site downtime. What's the best way to do this?

  • Vaughan
    • Support/SLS MockingJay

    hi @timstrifler

    thanks for posting.

    there's 2 ways you can do this.

    1 is to move all the files over to the top domain folder (usually public_html)

    then you'll need to edit wp-config.php to change the paths over etc. you'll probably also need to change some paths over in the database. may help you here too.

    the other method involves using your CPanel & changing the document root of your site to that of your wordpress site.

    though you'll still need to change the URL's in wp-config.php & in the DB. but the absolute paths will not require changing, neither will you have to move any files.

    either way, there will be a little downtime, but the whole process really shouldn't take longer than half hour.

    hope this helps. if you need any further assistance, please let us know.


  • kevin_m__schafer
    • New Recruit

    Hi @timstrifler,

    When I created my first WordPress site in a sub-directory, I decided to leave it in there when I went online with it to keep my public_html folder clean and orderly -- in the event I wanted to create more sites within other sub-directories at a later time.

    What I did is copy -- copy! -- not move! -- the index.php file and place the copy outside of the sub-directory and also placed a copy of the .htaccess file outside of the sub-directory as well. I left everything else in place. This method can only be done with one sub-directory.

    In admin settings > general settings, I entered these URLs:

    WordPress Address (URL):

    Site Address (URL):

    Here's a link on about moving your site:

    When I went online with mine, I thought I had broken my site at first, but I forged ahead and kept following the directions. It worked!

    Someone much more experienced than me will, without a doubt, post to your question. I just thought I would offer up the idea of leaving the installation in the sub-directory.

    Is your new site a Mulitsite installation of WordPress? This is important to mention.

    FYI: For more installations in sub-directories within the public_html folder, you can use Addon Domains. An Addon Domain will display a clean URL with no indication that a site is installed in a sub-directory. I have about six sites, all in sub-directories, and the URLs displayed in the browser when visiting any of them never show the main domain, which is associated to the public_html directory. You just have to make sure you perform the Addon Domain before you perform the WordPress installation. It works better this way.

    I hope I helped.

    Best Regards,

  • timstrifler
    • The Incredible Code Injector

    Thank you both for your advice!

    @Kevin Schafer, I like your idea of leaving it in the sub directory. I didn't realize this was even an option. I read up on the WordPress codex and I think this may work.

    This section here I think describes it best:

    Is that the section you followed?

    The only part I'm confused about is the bottom where it states: "If you already have content in your site, see when your domain name or URLs change for how to deal with references to the old URL that will remain in the database."

    Did you use the script from this site?

  • kevin_m__schafer
    • New Recruit

    Hi @timstrifler,

    I'm glad you're getting it. Yes, this is the page with the instructions that I followed. At the time I moved a copy of my index.php and .htaccess files outside of the sub-directory folder, I never had to do anything with the database. The reason, I believe, is because the WordPress installation never moved from the sub-directory where it was originally installed.

    Before you do anything, make sure you access your public_html folder via FTP and download your sub-directory folder to your desktop. This is a backup of your installation. Next, through cPanel, go to the section for Databases and choose "phpMyAdmin." Select your database from the left side. When that loads, up above in the center of your screen you'll see "Export." Click on this and download it to your desktop. With these two backups, you can restore your WordPress site should something go wrong with the changing of the URLs.

    FYI: At no time should you be without an index.php or index.html file -- of any kind, whether that of your old site or new site -- in your public_html folder. If you remove it and a visitor types your domain name in to their browser, they will be shown the entire contents of your public_html folder. All of your sub-directories and files will be on display.

    Do look into Addon Domain in cPanel. You simply set up the desired domain name and point it to the sub-directory. That's it. Website forwarding, basic and premium versions, offered by hosting companies don't work very well with WordPress. I always stay away from them. With Addon Domain, the index.php and .htaccess files reside only in the folder with the rest of the installation. There's no need to have anything outside in the pubic_html folder to make it work.

    I've never applied Addon Domain after I've installed WordPress. I know that when WordPress is installed in a sub-directory without this feature, the sub-directory name is part of the URL in Dashboard > Settings.

    If you make the two backups like I've mentioned, you can't go wrong -- permanently, that is. If your site breaks, which may happen, you can restore it.

    I hope this information helps. From now on, set up Addon Domain before you install WordPress, then you won't have to worry about moving anything. I wish someone would have told me all that I'm telling you a year ago.


  • timstrifler
    • The Incredible Code Injector

    Thank so much! This all seems like it's going to work. I do have one more question though @Kevin Schafer :

    You mentioned setting up the addon domain in cPanel. What if I don't need to add a new domain? The domain I will be using is already pointing to the root folder. Do I need to add the domain as an addon on domain and point it to the subfolder? My understanding is once the .htaccess is changed, it will automatically look at the subdirectory. Wha are your thoughts on this?

  • kevin_m__schafer
    • New Recruit

    Hi @timstrifler,

    You would mainly use Addon Domain for additional site installs inside of sub-directories in your public_html folder. The term "Addon Domain" is the feature's name, and it's basically used as a redirect for any of the domain names that you own. Its biggest benefit is that regardless of what you point it at, the URL in the browser will display the addon name of your choosing. This is called a "Clean URL." Without Addon Domain, the sub-domain names will always be proceeded by the main account. For example, my site,, is really My main domain name is Addon Domain allows me to have a site (really, a multisite) called Gumpolen, and when someone goes to it and it loads in their browser, the address bar simply reads, "" No other feature while using sub-directories can produce a clean URL like Addon Domain.

    If your domain name is already associated with the root folder (public_html), as in it being your main domain name for your hosting account, you won't need to use the Addon Domain feature -- you're right about that.

    My public_html folder has about eight sub-directories in it (all containing installations), and one each of the files .htaccess and index.php. These are both for the very first site that I set up, which still resides in one of the sub-directories. I don't use this particular WordPress site too often, but at least its index file keeps my other folders from being viewed by the public. I may install the "Under Construction" plugin on it, just to provide a blank screen with a single-sentence message.

    I think you have it nailed, and I hope it goes smoothly for you. It's all a good learning experience, that's for sure.


  • timstrifler
    • The Incredible Code Injector

    Hi @Kevin Schafer

    So I made the switch and everything went according to plan! It was very smooth, with no downtime whatsoever. Thanks again for your assistance! Yet again I am beyond happy with the level of community here at wpmudev!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.