How do I move WordPress from a subdirectory to the root directory?

Q. I’ve installed my website in a subdirectory of our domain, because I didn’t want visitors to see the site until I was finished with our development.

Now I want to have the site show up in the root directory (not in the directory). How do I do this? I’ve read the information on moving WordPress, and it seems really complicated.

A. The good news is that you DO NOT need to MOVE WordPress in order to have your content display without the subdirectory name. You only need to move 1 file and change one line of code and make one modification to your General Settings, and you’re good to go (see instructions below).

Installing WordPress in a subdirectory can be a good idea because:

  • It keeps your root directory clean and tidy (in case you need to add any other PHP applications to your site).
  • It adds a layer of security through obscurity by obscuring the location of your WordPress application files. Ideally, you want to name the subdirectory something not too obvious (ie don’t call it wp or WordPress). I’m not sure how obscure this really makes WordPress, because you can obviously get the subdirectory name from any images uploaded to the site, since they will still read as, so I usually install WP in a subdirectory for development purposes or to simply keep the root directory clean in case I install any subdomains or other applications.
  • It allows you to develop a new WordPress site while maintaining your current website in the root directory. Once you’re finished with your WordPress development, you can backup and then delete your current site’s files, and use the following instructions to display WordPress from the root directory of the site.

Note: If this is an older site, you will need to create 301 redirects to redirect your old page/post URLs to the new page/post URLs. Also, if you have a lot of internal hyperlinks, you will need to manually update those.

Before attempting to move WordPress

a) Clear ALL pages cached by your caching plugin cache AND then de-activate the caching plugin. Also, de-activate Broken Link Checker and any Redirection plugins;

b) Remove any old site files from the root directory — perhaps copy them to a folder called _backup – this includes an index.html file which will totally make this process not work. You MUST remove all those old site files and folders or move them into another directory, so they don’t interfere with WordPress. Having an index.html and index.php in the same folder causes confusion, and likely, the index.html will be used instead of WordPress’ index.php file;

c) Make sure you don’t have any other folders in the root directory that have the same name as any pages on your WordPress site, for example “blog” unless of course this is the name of your subdirectory install of WordPress in which case you cannot have a page of the same name because the browser will get confused and look for that page in that folder, then things are really confused;

d) Use wp-db-backup to make a backup of your database –;

e) Be sure you have access to your database via phpMyAdmin on your web host’s control panel in case you type the URLs wrong in the next step. Your database username and password are in the wp-config.php file.

Displaying WordPress URLs from root directory when WordPress is installed in a sub directory

1. Login to the WordPress Dashboard. From the Settings -> General tab, set your WordPress address URL to the subdirectory you installed WordPress in (without the trailing slash). Note: This will already be displayed in the WordPress address field, so you don’t have to change it. What you do need to change is the Site address URL. Set this to  your site’s root address (without the trailing slash).

2. Using an FTP application or your web host’s File Manager, DOWNLOAD the index.php file that is in the WordPress application directory (not the one in your theme’s folder or elsewhere) and then UPLOAD the copy you downloaded to the root directory. (By root, I mean the www, htdocs, or httpdocs folder — NOT the root of your hosting account! You simply want to upload the copy of the index.php file and put it in the parent folder of your subdirectory which presumably is the location for the main URL of your website.)

Alternately, you can use your FTP application and MOVE the index.php “to the parent” but then you MUST read and follow step 6 below.

(Note: If you have a site already in the root directory, such as an old static html site, then you should backup and delete those files first.)

3. In a text or HTML editor, open the index.php file that you just copied and/or moved to the root (aka main url) directory and change the location of your wp-blog-header.php to tell WordPress where it can find the WordPress application files in the subdirectory:

Example: if your WordPress installation folder is ‘mywp’, you would change:

require( dirname( __FILE__ ) . '/wp-blog-header.php' );


require( dirname( __FILE__ ) . '/mywp/wp-blog-header.php' );

Important: Be sure you type this correctly! A missing / or too many slashes or missing period or apostrophe can make this not work. Believe me, I’ve seen people be totally freaked out things didn’t work and it was because they typed this line wrong.

4. Visit the site and click an interior page to make sure it displays correctly. If it doesn’t, you may need to update your permalinks (Settings -> Permalinks and click Save Changes). If you still cannot access your interior pages, then the .htaccess may need to be moved to the same location as the index.php file (i.e. the root directory). This is not necessary on all web hosts. Be sure to update the permalinks again after you move the .htaccess file.

Remember that your login and registration links will still be

Now, when people visit your site, they will see all the URLs of all the pages and posts as if you had installed WordPress in the root directory, and you will have a neat WordPress directory behind the scenes.

Note: If the site you are redirecting to the root previously was your live site, and you have a lot of posts whose URLs you do not want to change, then you should change your Permalink structure to INCLUDE the old subdirectory name (e.g. mywp), so none of your post hyperlinks break. For example:


The /mywp/ will only be in the URL of the posts, not the pages.

5. Create a “Silence is Golden” index.php file in the WordPress directory.

If you copied the index.php file instead of moved it, this step is optional. Essentially, you don’t “need” this duplicate index.php file in the subdirectory because it doesn’t really do anything other than prevent people from reading the directory contents. However, if you moved the index.php file leaving the WP directory without an index.php file, then you should create a new blank index.php file and put the following code in the file:

[php]<!–?php // Silence is golden. ?–>[/php]


If you have any trouble with this process, please visit my Moving WordPress from Subdirectory to Root FAQ.


If this process was successful, please comment with a thumbs UP below, share on Twitter, follow me on Facebook. Thanks!!!

Angela Bowman

Front-end WordPress developer since 2007 building highly custom websites for nonprofits and small businesses. Experienced in nonprofit administration, grant writing, and technical writing. Love high altitude hiking and backyard chickens.

View all posts by Angela Bowman

957 comments on “How do I move WordPress from a subdirectory to the root directory?

  1. A thousand, thousand thanks for the (mostly) simple explanation of how to run a site from a sub-directory. Even I – thick as two short planks – managed to do it. Eventually.
    I wonder if a word of warning might be in order. I’ve got a huge number of internal links on my site. The normal menu worked as expected, but all the page-to-page things had (have – it’s taking ages) to be re-done.
    Thank you, thank you, thank you.
    And now for a glass of something red.

    • Thanks, Ian. I had that on the post at one point. I just added it back in. Great feedback. Glad it was successful for you. If you had any page rank in Google for the old URLs, you will want to create 301 redirects for those so they don’t display as 404 not found in the Google Search results and the page rank will be transferred to the new URLs. I like the Quick Page/Post Redirect plugin for this:

      Avoid wildcard redirects as that will mess with your images and other uploaded media and WP core URLs.

      Good luck! Angela

  2. Hi Angela

    Thanks for a wonderful tutorial – that really helped me.
    Everything works now except from the main redirect – maybe you have a moment to help me:)
    I have now moved my site to, and everything works perfect after changing som links.
    Futhermore I have made som 301 redirects in my .htaccess file in the root. This is because I have many links from other sides around the internet linking to my site. I managed to get every pag to work except from the main site.

    So if someone write – they get redirected to
    but if they write they are not redirected – because of the index.php file “silence is gold”:)

    If I set a redirect in that one, everything works, but I cannot enter my admin… jiha:)

    Any suggestions?

    All the best
    Morten Hilmer

    • I think if you are careful with your redirect and don’t do any sort of wildcard redirection on it, it should work. I do that quite often, actually, when using this technique. Redirects can be so complicated, so you want to do a simple 301 redirect for this, e.g.:

      Redirect 301 /da

      You might want to test with 302, so it doesn’t get cached by the browser if it doesn’t work. Let me know if that works okay for you.

  3. Good Day!

    Pretty new to WP, just want to ask also since I have a fantastic site installed in the root directory which is working perfectly now. My problem is, I purchased a new domain and I installed WP in the subdirectory because I dont want to mess up my currrent site, Now that I have finished the development of the website which was installed in the subdirectory, I want the URL to be:
    How can I have both site working? I saw in your instruction that index.php need to be move to the root directory but the problem is there was an existing index.php that belongs to my original site. Do I need to overwrite it.
    Please advise. Thanks!

    • Hi Rick,

      If your original site is going away, then you can overwrite the index.php file that is there. If you are going to keep the original site, then you can’t have both sites using the root directory. There are creative ways to handle this. Let me know what your plans are.


  4. Hi Angela,

    You may have already answered my question but wow lots of comments here.

    Ive moved a site to a sub directory, no problem kinda.

    When I go to the admin login, it redirects to include the sub folder, the issue is when I login I get access to admin okay but when I view a page the edit bar at the top of the site dissapears so no quick editing of a page?

    Would this be a .htaccess issue, do you have an example of what the .htaccess file should look like?


    • Hi Bjarni,

      Glad via email we got this figured out and narrowed it down to your browser cookies needing to be deleted.

      Have a great day.


        • Hi Matthew,

          I was out of town and got a bit behind on replies. Have you tried logging in with a different browser? Let me know if you still need help. Feel free to use my contact page to email me directly.


  5. Just THANK YOU!:) After full day of googling and browsing useless hyper technical forums this was the first HELPFULL article.

  6. I’m working on a site that is hosted with Yahoo Small Business (blah). I tried following your instructions, but I am running into two issues…

    1) There is no public_html, www, htdocs, or root directory folder of any kind. The current site files are in “/”. Should I create a public_html directory? Should I just put the index.php in “/”?

    2) I can’t find the .htaccess file anywhere. I am using Filezilla and have “force showing hidden files” on, but I still can’t find .htaccess.

  7. Thank you so much!
    This tutorial worked perfectly for me.
    I was breaking a sweat worrying about this as it was my first time creating & uploading a custom WordPress site but this worked flawlessly. Can’t thank you enough!

  8. THANKYOU!!! You totally just saved me. I searched everywhere and no one explained this in such a simple step by step way like you have here. I’m setting up a clients page and for the first time in all my experience with WordPress it installed in a subdirectory (I still dont know why!), and I had no idea how to fix it. Its all fixed now thanks to you! 🙂

    • Hi Jean-Paul, I’m glad that worked well for you. You are second person to write to me from Cuijk. I will be in Netherlands this summer. Looking forward to being there.

  9. Hi Angela, really a great description and it works fine – within the moved wp-site for the most parts.
    But now, all my other content in the root, from where I moved, is not accessable. (e.g. downloads and other, non wp stuff) and some graphic parts (from style.css?) like list-style-types (bullets) are not shown.
    The path to the “old” root and content is: /webspace/httpdocs/ with several subdir like /downloads
    The path to the wp direcory: /webspace/siteapps/WordPress/htdocs
    What should I do? Clear the old directory and move all content to the new location?
    Have I to add some code for the css?

    • Hi Udo,

      A couple things:

      1 – Any paths in the style.css should not include the full path. Only the path relative to the style.css directory.

      2 – If we are talking about the site, it looks like all the assets are loading from which would be inefficient.

      I’m wondering if you can describe what happened? Were you moving the site to a new domain name? Let me know! I think you would want to change the Settings > General both URLs to the new domain name, then move the site to the folder that is considered the root folder for that domain name, then run the Velvet Blue Update URLs plugin to rewrite all the old URLs to use the new URLs. Let me know if you get stuck.

      • Hi Angela,
        I know what you see is confusing but the background is quite simple. Both domains are pointing to the same host, the wp site (originally only a blog) was in the subdir./siteapps/blog/ and the main site (pure html version) was located in the root /httpdocs/ The main site was primarely adressed as “neptunreal” but you also could find the site under the second domain too.
        Then I built a new site including the “blog” on the existing wp-base using a new theme. Now I wanted to cancel the old html-site and have only access to the new wp-site without the subdir “blog” in the URL
        Looking for a simple solution to do that I found your article. All is fine after following your tipps except that I cannot access the stuff in the old “root”. The issue with the assets I have to clear with the provider.
        Do you really think it will work,, simple copy (move) all the wp content from one directory to the other and then let the Velvet Blue Update URL plugin rewrite the URLs?
        Or should I proceed as I would install a new wp site (what I wanted to avoid).
        Thanks for your suggestions!

  10. Thank you! Thank you! Thank You! After reading all these convoluted method, the dryly written info in the WordPress Codex, and the tech support “experts” from my webhost trying all these crazy htacess rules breaking my site left and right I found your post which JUST WORKED simply and perfectly. I also liked the added explanation of why this is good method for hosting a wordpress site! Well done and expertly written!

    • Awesome, Mike! Yes, this is so super simple. I like to explain it, because it doesn’t require a lot of work and works perfectly fine.

      If you ever DO want to physically MOVE everything, I wrote a post on how to do that as well:

      It’s half a dozen one and six of the other. The method you used is just few steps and fewer things to go wrong.

  11. Hi there
    I’ve been using your excellent method for a lot of sites and thank you so much for an excellent solution.

    I recently had a clients WordPress install that was causing problems that I won’t bore you with. I wondered if a workaround might be to recreate the site in a new subfolder – new install, new database. I’ve done this and just altered the line in the index.php in the root to the new subfolder and changed the settings in the new install. The site shows correctly, the home page header image is using the new folder, but all the internal pages images are coming from the original subfolder, the availability page (it’s a cottage for holiday let) is displaying the information in the original database. I have saved the permalinks and cleared my browser cache. If I try renaming the original subfolder, I get a 500 error.

    Have I missed a step, or have I misused your excellent method in thinking that I can do this? Any advice will be greatly appreciated.


    • Hi Rowena,

      Yes, what you did should technically work. I’ve done the same thing before.

      You might need to rename the .htaccess file and then go to Settings > Permalinks and click Save Changes to regenerate the permalink.

      Did you change the Settings > General URLs to use the new subdirectory for the WP URL and the root for the site url?

      Let me know if you still have issues. I think the .htaccess is probably the issue or any custom links on the pages.


      • Thank you for your prompt reply Angela – much appreciated.

        The subfolder setting is correct in the General Settings. I tried renaming the .htaccess file and the internal pages of the site broke with 400 errors. I had a look at the content of the .htaccess file and there was mention of the original subfolder name. I amended that to the new subfolder and saved it to the site (properly renamed again) – it made no different. The pages are getting their content from the original installation. There is an availability calendar in the site and that content of that is definitely coming from the original database, not the new.

        In case it’s relevant, I tried doing this whole new install because suddenly the site suffered from the issue that some encounter where the WordPress and plugin updates cannot be performed. Apparently a permissions/ownership problem, I could not fix it. So I figured that a fresh install might be an avenue worth taking.

        Thanks for your help Angela – it’s much appreciated.


        • When you rename the .htaccess, the pages will show as 404, of course. So, what you need to do which you may have skipped is go to Settings > Permalinks and click Save Changes. That will create a NEW working .htaccess.

          Please check your index.php file in the public_html folder and make sure that has the correct subdirectory. Right now, it appears to be using _wpgc.

          • Hi Angela
            Thank you. I had saved the permalinks, but the .htaccess was not writeable, so had not recreated. I’ve created it by hand.

            Thanks so much, as someone else said, you are an angel.


  12. Hello,
    I am reaching out because I am stuck. I have backed-up my entire DB, copied the entire html/ file containing my wordpress site to a sub directory of my new site on a whole new server. I connected the new DB in the wordpress config file and used the following .htaccess inside the blog/ which is the stock wp .htaccess.

    However, my problem is the actual rendering site pages/posts and some images. It cant seem to find them, and seems to be re routing the blog pages to as opposed to, which is only making matters worse.

    Can you help with this?

  13. Hi Angela,

    Just thought to give you kudos! This tuto has helped me multiple times on setting my friends & fam wp-blog, now it helps me once more. You’re also very kind & thorough on your replies, thank you!

  14. Hi Angela,

    So I have a new WordPress site for our gallery in a subdirectory (/wordpress). I’ve attempted making it the main site with the directions found at the top of the page, which I initially found here: Both, “Moving a Root install to its own directory” and “Using a pre-existing subdirectory install” came back with the same results. “/wordpress/wp-admin/” brought me to an admin page with no styling. After submitting credentials, I was redirected to a page (path no longer contained “/wordpress/”) that could not be found. “/wordpress/wp-login.php” could not be found. The index.php page appeared, but with broken styles. Some images appeared, some did not (see screenshot here: Javascript functionality was also broken. I looked at the code and noticed the images that rendered correctly had permalinks referenced “/wordpress” (see screenshot here: The other images, styling, javascript, etc., that did not function, referenced the root folder (see screenshot here: I guarantee that I went through all of the initial steps correctly, as I’ve done them multiple times alone, with my hosting provider and with WordPress support (via forums). To note, my site does not have a .htaccess file—just a web.config file. Although, I have tried creating a .htaccess file and added the rewrite code, but had no luck. Another thing to note, the site is on a Microsoft-IIS/8.5 server.

    I’m wondering if my custom permalink structure has anything to do with this. I’m using “/%category%/%postname%/” in the WP dashboard.

    WordPress support is asking me to try downloading all of the old site files, then delete them on FTP so that the /wordpress folder is the only site there. I’m not sure this is the right thing to do or not—he even said “this is a bit radical.” Anyways, you seem awfully knowledgable about the subject at hand. Could you please provide some guidance? I’ve been troubleshooting this issue for several days now and the gallery I’m working for is getting antsy, as we were supposed to launch last week.


    • Hi Paul,

      It looks like you have things back to where you started with WordPress still in the subdirectory. You commented on my post: which has the step-by-step instructions for keeping WordPress in the subdirectory but allowing the URLs for your posts and pages to show from the root. With my instructions, you would still login to the site via the subdirectory, but you should see all the URLs show from the root of the site.

      Because sometimes people might make a little typo or encounter other errors with this process (usually as the result of some small typo), I created this FAQ:

      At any rate, I can usually solve these issues in under a half hour – sometimes in just a few minutes. I’m heading out now to a meeting, but I can help you when I return. Please email me via my contact form: I’ll reply back to get your WordPress credentials and web hosting login. I can accept payment via Paypal for my time, which should be minimal.


  15. I cannot find any line in the index.php files that has the words “wp-blog-header.php” anywhere.

    How many index.php files are there supposed to be and where are their locations?

    Found one that already had the Silence is Golden entries.

    And when you say to copy one file to the htdocs folder, which one of the index.php files should be copied? And is there any other line that should be changed if I can’t find the wp-blog-header.php file?

    Thanks much for any help.

    • Hi,

      The index.php file I’m referring to is the one in the main WordPress install – so the highest level of the WordPress installation where the wp-admin and wp-includes folder are. Yes, there are many index.php files that serve different purposes. This one controls the root level of your site.


      • I don’t have “many” index.php files, not that I have seen. I only have two index.php files, and they are in the wp-admin and wp-content folders (which are in htdocs). Other wp files are in a subfolder called leespad. The index.php file that is in the wp-content folder is the Silence is Golden one. The one in the wp-admin folder is code, 6 printed pages of it. Is this the one that should be copied to the htdocs folder? As I said, I cannot find any line in that file that has “wp-blog-header.php” in it. Again, is there some other line that should be changed, since I can’t find this particular line that you say to edit? Should I add this line somewhere? I do not know code but I could try with an example to follow. Thanks much for any help that you can be in helping me to get this website going. Right now, my old website comes up. I have the WP website ready but can’t get it come load instead of the old site.

        • index.php files are found in many folders of the WordPress installation including the ones you have noted.

          The one you will need to copy and move to the root directory (aka public_html directory) is the one that is with the other WordPress installation files. This is at the same level of as the wp-admin, wp-includes, and wp-content folders but NOT inside those folders. In your subdirectory where you have WordPress installed there are the following files:

          .htaccess – invisible file
          index.php – this is the file you will need to download and upload to the public_html folder and modify the require line
          wp-admin – folder
          wp-content – folder
          wp-includes – folder

          • Sorry, but neither of your replies to my inquiries was what I needed or was looking for. However, the good news is, after several hours, I was able to figure it out myself and the site is now online. I think there was a bad installation. There was no index.php file in with the three main wp folders. But I found one that worked after I moved it and changed a line in it, along with changing a path in the Dashboard and making sure the pointer was right on the web host’s control panel.. I never found an index.php file with the line “wp-blog-header.php” reference in it. The three main wp folders are in two places, but since it works, I won’t mess with it any more. I did several things and don’t remember a lot of what I did, but finally got the right combination of things. to make it work.

          • The index.php file that is referred to in this post is NOT in one of the WP folders. It is in the main installation of WordPress — NOT in the wp-content, NOT in the wp-admin, and NOT in the wp-includes folders. EVERY WordPress site has this index.php file in with the main installation files. There is not a single WordPress site in the Universe that doesn’t contain this file.

            At any rate, I’m glad you finally found it and figured it out.

  16. Angela, that was just tooooooooooooo easy!

    Many thanks for such a great article. I got in touch with you about 6 months back when I was in the early stages of converting an existing static html site to wordpress. I completed this over Christmas and just flicked the switch with the help of your instructions – it’s great to have it over and to now have the flexibility of the new platform.

    A few questions popped into my mind whilst doing it:

    Are there any disadvantages to using this quick method as opposed to your more detailed ‘full move’ method. Are there any gotchas coming down the track as my site develops?

    I’ve set up 301 redirects using the Redirection plugin. I have another plugin which can apply compression to my site by adding code to my htaccess file……. is this likely to affect any redirections set up?

    Does EVERYTHING now see this site as present in the root as opposed to a sub directory? I’m thinking about things like analytics tools, search engines etc?

    Thank you again – you are a legend.

    • Hi Stephen,

      All the page and post URLs will be from the root. Your login and any files uploaded to the Media Library will display from the subdirectory, hence why your subdirectory should be a professional-sounding name (not test or dev). I usually make the subdirectory something benign, like the initials of the company.

      Otherwise, from an SEO standpoint, there isn’t really any downfall if you do all your 301 redirects from the OLD url for the posts to the new one. This is hard to do wild card because then you might get the wp-content media items as well, which would not be good. So, I would recommend doing the rewrites singly unless you have some good .htaccess fu.

  17. Hi Angela, thanks for the information. I run a website and while setting up WP via Softaculous, I kept everything to default and then realized it actually installed in a subdirectory /wp. So then my website URL was However, instead of installing it again I solved the problem and somehow managed to move the files to the root directory and got my website URL to and made changes in the Settings option in WP admin portal. Although my WP installation and website are in the root folder, whenever I install a new plugin or make changes, they take place in /wp folder and not the root directory. So I manually need to transfer the plugin folder to root folder. For instance from “/wp/wp-content/plugins/example_plugin” to /wp-content/plugins/example_plugin” using FTP from CPanel. Everything was fine until I lost my Google Adsense plugin control due to instability and Ads won’t show up. I have been troubleshooting the problem since last week. I think the situation mentioned above is creating this problem. I don’t know what I was thinking, but I replaced all the files and folder from /wp folder to root. Anyways, I want to make root directory as my default directory fro WP so that I don’t need to replace the files whenever I make changes. What am I missing here? What should I do to make the root directory as default directory?

    • Hi Sarang,

      If you MOVED all the WP files including the wp-content folder to the root and changed the Settings > General URLs BOTH to the root URL, the plugins should no longer install in the subdirectory. Be sure to check the index.php file on the root install and make sure it doesn’t have the subdirectory listed in the require line and also check your .htaccess file and make sure it’s not redirecting the site to the subdirectory, which I doubt is issue but good to check. Lastly, check your wp-config.php file and make sure it is not referencing the subdirectory either.

      Do you have any files in the subdirectory at this point? You might try moving the subdirectory folder way up above the public_html folder — to the root of the hosting account — to just get it out of the way while you troubleshoot.

      • Thanks for the reply. I solved the Google Ads issue. It seems I enabled PageSpeed from CPanel and that’s when I lost Ads. Now that I have solved it, I am focused on the WordPress issue. So I use Yoast SEO plugin and created a robot.txt file and found that the robot.txt file has this code:
        User-agent: *
        Disallow: /wp/wp-admin/
        Allow: /wp/wp-admin/admin-ajax.php
        Should I go ahead and remove the /wp from the code and save it?
        At this point, I am too afraid to do it because I can’t afford to lose my site again. I have crashed my site many times before solving this issue. I have moved everything from /wp to root i.e., in public_html

        • Okay, that makes sense. I have removed all the disallows to the wp folders. The only thing I disallow is indexing of a folder I have that contains some images I don’t want indexed. Here’s what Yoast says about this:

          Blocking your /wp-admin/ folder

          In the comments many people asked whether I think you should block your /wp-admin/ folder. I think you shouldn’t. The reason is simple: if you block it, but link to it a few times, people will still be able to do a simple “inurl:wp-admin” query and find your site. This type of query is the type of query malicious hackers love to do. If you don’t do anything, WordPress has (by my doing) a robots meta x-http header on the admin pages that prevents search engines from showing these pages in the search results, a much cleaner solution.

  18. Wow!

    You are my hero! I can’t believe that something so simple has been made so complicated on the internet. I just moved my index.php file and it took all of 2 minutes but the other resources I saw on the internet were just insane (requiring a move of ALL files and creating new directories etc etc.)

    I am so glad I found your site! I will be a regular now 🙂

    You absolutely rock!

    • Hi Penny,

      I do love this method. I wrote another blog post explaining how to do it the “hard way” because some people don’t want to live with the subdirectory for the upload content. But, I’m with you! I’m glad there is this easy way to do it!


  19. Thank you so much for this post!

    I was so frustrated with this url problem and my hoster’s support about it is so imposible to understand for people who barely know about this subject… finding your post made it so much simplier and understandable and saved my day 😛

    Glad there is ppl out there giving a hand on this. Great job and thank you once more!

    • Hi Amanda,

      In your case, I don’t recommend using capitalized letters in your subdirectory as that could cause a lot of issues with various themes and plugins when you try to show pages and content from the root. They may not be able to find their files because they assume a lowercase lettering.

      To make the new site live, since you have to not use that subdirectory anyway, I would do the following:

      1 – Move all the current HTML files from the old site into a folder.

      2 – In your General Settings, change both fields to use the root domain name, e.g.

      3 – Physically MOVE ALL of the WordPress files into the root (public_html) folder.

      4 – Login to WordPress and install the Velvet Blue URLs plugin and do a rewrite of the URLs from the old subdirectory URL to the new URL.

      5 – Go to Settings > Permalinks and click save changes.

      6 – Check for any Custom Menu items under Appearance > Menus. Be sure your home page link uses the root URL.

        • First, subdomain is different than subdirectory. A subdomain is set up as a “subdomain” in the hosting control panel and displays as A subdomain will typically live inside a subdirectory of your hosting account, but that is not the same as “installing WordPress in a subdirectory.” Installing WordPress in a subdirectory does not require setting up a subdomain and simply is an installation inside a subdirectory of the primary domain, e.g.

          Most hosts will NOT support redirecting the document root of the primary domain to a subdirectory, hence why your two choices for getting your WordPress installation that is inside a subdirectory to show the URLs from the root would be to physical MOVE the entire installation to the public_html folder OR do the process I’ve outlined here. Many people may have installed WordPress inside a subdirectory because they had a static HTML site to start with and installed WordPress as a “blog” but now want to use WordPress as their main site.

          Some hosts may allow you to point the primary domain to a subdirectory, but you should check with them first.

  20. Great instructions – thanks for posting this.

    I was upgrading from a Drupal site to WordPress. I put the Drupal site in offline mode, then went into cpanel and created a folder called something like drupal_site_old. Then moved all the stuff pertaining to the Drupal site in there. Then followed the instructions for moving the WordPress development site to the root.

    The only hitch was the backup plugin recommended. It hung up and didn’t work for my WP 4.31 site. Updraft Plus worked fine.

    • Thanks for the tip on Updraft Plus. I am going to write a more comprehensive manual for “migrating” WordPress, as this post is one very specific method, but people usually need more step-by-step instructions for other methods such as really “moving” the install. There are a few ways to handle that, and using Updraft Plus, Duplicator, or BackupBuddy or other Migration plugin are options to physically MOVE the install the public_html directory and have the plugin rewrite all the URLs automatically.

  21. Hi Angela,
    when setting up my site 2 years ago, I had moved WP into a (fancy named) subdirectory because I had read somewhere that this is more secure. In the meantime I had started to wonder about this argumentation as I noticed that all my images showed my “secret” fancy wordpress folder name.
    You actually mention this on the top of your post:

    It adds another layer of security by obscuring the location of your WordPress application files. Ideally, you want to name the subdirectory something not too obvious (ie don’t call it wp or WordPress). I’m not sure how obscure this really makes WordPress, because you can obviously get the subdirectory name from any images uploaded to the site, since they will still read as,

    Anything new you can say to this? I’m now thinking of moving all my images to a new folder in root or maybe even to a subdomain to avoid this problem.

    Interested to hear your opinion about this.


    • Hi Michael, That’s a very good point. Many bots will target the main URL with /wp-content to get to vulnerabilities in themes and plugins. However, the bots have gotten smarter and might be able to dig deeper into the site anyway. Also, security through obscurity really isn’t security. I’m in the process of writing a bunch of how-to tutorials on “moving” and “migrating” WordPress since some people don’t want to keep the install in the subfolder. My purpose for writing this tutorial is that many people do want to keep the site in the subfolder but just show the URLs from the root, and at the time, the only tutorial out there was on a site that had been hacked.

      At any rate, the subfolder name is NOT secret, and I never would have suggested that it is, because it can be easily seen in the URLs for all uploads, themes, and plugins. I might have that more clearly elucidated in the FAQ post. The main purpose for keeping WordPress in a subdirectory is for convenience and to keep the root directory clean in case you have other WP installs or subdomains on the same hosting account (which isn’t a great idea anyway). The potential security benefit is more for bots looking for the wp-content folder at the root, not that you can’t see it or find it.

      So, yes, by all means, you can MOVE the ENTIRE WordPress install to the root aka public_html directory. To do this:

      1 – Go to Settings > General. Change BOTH URLs to show from the root with no trailing forward slash, e.g.

      2 – In your FTP application, MOVE everything out of the subdirectory to the root of your install.

      3 – Login to your site and install the Velvet Blue Update URLs plugin and rewrite all your URLs from the subdirectory URL to the root e.g.

      You may have broken 404 links to uploaded images if people linked to those externally (which they shouldn’t).

      You can also use regular expression in the Redirection plugin to rewrite the previous uploads folder contents to the new url for the uploads folder.

  22. Hi Angela,

    Great article! A couple of questions for you. First, I haven’t set up my company’s website yet, but I do know that there will be two versions. The first year will be for marketing and, after that, a second site or version will be launched for operations (the first site will be removed once the second is live, but the second will be in development while the first is live). We will be using the same domain name for both, so does it make sense to set up both sites in separate directories? My second question pertains to a SSL. As we want to remain secure to avoid malicious hits and hacking, are there any issues I should keep in mind while installing a security certificate and dealing with wordpress in a subdirectory? If this is my approach will using subdirectories force me to install wordpress twice in both directories? Is that even an option? I really don’t want to go the wordpress multisite route as, in the end, only one site will be live at a time.

    Thanks in advance for your assistance!

    • Hi Tony,

      There are a couple ways to approach this:

      1 – Simply install WordPress in the root for the first-year site.

      2 – Install the dev site in a subdomain (which will technically live inside of a subdirectory on your server) and migrate from the subdomain to the root when you are ready to go live with that site.

      The reason to perhaps start and stay in the root is to avoid having 404 errors on any uploaded files. By not switching directories, you have a more seamless transition. The reason for my post is that so many people started to build their sites in subdirectories and then couldn’t figure out how to show it from the root. It’s also not a bad thing to do. However, I’ve recently started hosting a lot of my sites at WP Engine, and they don’t allow subdirectory installs. If you think you will migrate at some point to a managed WordPress host, having the install in the root would be easier all around.

      As far as SSL, the SSL typically applies to the primary domain for the site, regardless of where the WordPress files are living — it covers the whole root domain. What the SSL will NOT cover are subdomains. You would need to purchase a wildcard SSL that will cover all domains, including the subdomains, or get a separate SSL for any subdomains.

      I hope that helps! Let me know if you have more questions.


  23. Cancel what I said about not being able to edit my posts/pages and preview posts before they’re published. I learned that after I logged out, and then logged back in, that the problem was resolved.

    It’s a good thing I realized this before I went to the trouble of moving those core files and messing with the permalinks again. Whew!. 🙂

    • Yes!!! Oh my goodness. Glad you did log out and log back in. I’ll make a note of that on my post. The cookies can get confused when you switch things.

  24. As many others here have said, thank you for a well explained and easy to follow instructions on this subject. My hosting site is which does not allow wordpress to be installed into the root directory. I went ahead with installation in a subdirectory and began designing my new site without any idea how to replace the old site once I was finished. This did the trick and only took about 5 minutes which is amazing considering I had no WordPress knowledge just a few weeks ago.

  25. Hi Angela,

    Thanks for all you do.
    I followed your instructions and dozens of others but still can’t shake that “wordpress1” that sits at the end of our domain. displays fine without “wordpress1” but when you type you still get
    Any advice or fix would be greatly appreciated.

    Thank you so much!

  26. Our development site was built (stupidly, I now realise) in a subfolder called /blog.

    What is the best way of changing this directory name and moving the site to root please?!

    “Make sure you don’t have any other folders in the root directory that have the same name as any pages on your WordPress site, for example “blog”


    • Hi Lindsey, You wrote to me directly via email, so I can reply there as well.

      In terms of getting you out of this mess, you can edit your URLs back to what they were in phpMyAdmin wp_options table. I have the instructions in the post. Once you do that and can log back in, you can do one of the following:

      1 – Actually MOVE the site out of the blog folder (change General Settings to the root domain name, then move all the files to the public_html folder, login again, and run the Velvet Blue URLs plugin to rewrite all the URLs on the site).

      2 – Or rename slug aka permalink for the page called blog to something like our-blog and repeat the process in my post, and you won’t have the conflict.

      I hope this helps. Email me if you get stuck.

  27. Thanks for the well explained post. I’m having a challenge however. I can’t find the site url or address under the general tab of admin settings panel. Just the site name, email and others. Please help me out. Thanks

    • Hi, it sounds like you probably are running a site on multi-site in which case these instructions won’t apply.

  28. Really, thanks. Your presentation was very clear and everything worked fine! I was getting very upset reading other sites, including I was enlightened I stumbled on your site!

  29. Thank you so much for these clear instructions.

    I’d read loads of others sites and I was TERRIFIED of doing this, but thanks to you I’ve done this no problem!

  30. Hi, just two questions before I try it please.

    1. Does the original index file residing in the sub-directory absolutely need to be replaced by the Silence is Golden index file or can it left there unedited, as is, with an appropriately edited copy placed in the root?

    2. Pretty Permalinks: If I have been using them, do they need to be turned off at any point in the migration process?

    TIA! EE

    • Hi Elke,

      The index file that is originally in the subdirectory can stay there. No need to replace it with a Silence is Golden file. But if you MOVE it, you will definitely need a Silence is Golden file to prevent people from being able to list the contents of the subdirectory. Index files basically prevent directory listings by outsiders.

      I haven’t ever needed to turn off the Permalinks. Sometimes, I’ve needed to go to Settings > Permalinks and click Save Changes to have WordPress write the .htaccess where it wants it.

  31. Hi,

    Could you please assist me with this?

    I moved my WordPress sub-directory into the root folder and realized that it wasn’t the correct way. However when I moved it back to the original sub-directory and opened the link, the site has lost is formatting and now displays all wrong! Wha can I do to fix this?

    • Hi Lindley, Sorry for the late response. Can you contact me via my About page? I can probably help if you need some help.

  32. This is a great and helpful article, thanks.
    I am in the process of replacing an old html site with a wordpress site, and I’ve successfully installed WP in a new subdirectory, and intend to eventually do as you’ve instructed here.
    However, there is already an earlier installation of WP for a separate (although related) fully functional site in this same public_html folder, and the directory for that one IS in fact called “blog”. (uh oh!) I can’t actually change that, (it has another subdomain pointed at it, and lots of outside links to it as ‘/blog’.) Maybe I have shot myself in the foot with this?
    But what I’m hoping is that maybe you have some idea of a workaround or a way of setting things up in the NEW, second WP installation, (in which I haven’t even written a blog entry yet) so that it doesn’t mistakenly go looking in to the other WP installation directory called ‘blog’. Is this a possibility?

    Thanks very much for your time!

    “Make sure you don’t have any other folders in the root directory that have the same name as any pages on your WordPress site, for example “blog”

  33. Thanks for this, Is it possible to redirect from unused deleted website page to new website page using these redirect code..

    • Glad it worked. Let me know if you have questions in the future or think of something I should write about!

  34. Hey Angela!

    Thanks for the great article!

    Helped a ton!

    One question though(although it does already work):

    Whats the difference between require( dirname( __FILE__ ) and the one you are describing?

    Is it ok if i leave the require( dirname( __FILE__ ) rather than php require?

    Thanks in advance.


    • Hi Themis,

      Thanks for pointing this out. The more current version of WordPress uses:

      require( dirname( __FILE__ ) . '/wp-blog-header.php' ); without the opening and closing PHP tags. So, yes, you can use the line that is in your file. The main thing is to add your subfolder name to that line, so it reads:

      require( dirname( __FILE__ ) . '/subfolder/wp-blog-header.php' );

      Substitute the word subfolder for your subfolder name. What this does it tells WordPress where to find the WordPress application (as well as your themes, plugins, and uploads).

    • Oh, and now I realize you are referring to dirname(_FILE_). This was modified in WordPress core after I wrote this blog post because a core contributor felt that it was better practice to use the absolute rather than relative path. The dirname(_FILE_) uses the absolute path which resolves some issues on some servers such as Windows servers. For most people, this won’t make a difference, but for those that it does, using the new include line will work better. Here’s the WordPress core trac ticket about this change:

      • In Google Analytics it is showing wrong url in blocked and these URL in broken link, When i write post and publish two urls are creating like domainname and domainname/blog.

        • Hi Sachin,

          Can you go to my About page and write to me privately? I’d like to see an example of what you are talking about.



  35. Hi Angela,

    Great article, thanks for posting this.

    I have a static html site of approx. 25 pages. I have selected a theme and all I really want to do is move the pages over to preserve the domain SERPS. I am happy to recreate the pages by copy and pasting content the manual way given the small size of the site, but I just want to ensure that I am able to redirect traffic from old to new.

    I think I understand the concept of htaccess and 301 redirect but the thing stopping me is not understanding how the old homepage will be dealt with (index.html). I was looking to use the HTML Import 2 plugin to move my HTML pages to posts or pages in WP, which also generates a .htaccess output.

    If I install WP and generate the new pages and posts with the plugin in a sub dir as per your instructions how does this affect the redirects from the original root site pages?

    In short, I am dying to get it moved in the simplist way possible so I can get cracking in WP, but don’t want to hurt the serps as the site is 4 years old. I’m happy to not use the HTML Import 2 plugin and do it totally manually as long as:

    1) I can handle the redirects correctly
    2) I can make it look like it still sits in the root URL

    Any help you can offer would be a god send! I just don’t want to overcomplicate what might be a simple problem?



    • 1 – Install WordPress in a subdirectory so you don’t mess up your current site. You can’t have both running from the public_html (root) directory. Name the subdirectory something you can live with (as this will show if people see the source URL for images and uploaded files). I often use an acronym of the company. Lowercase and one word is best.

      2 – Copy over your content from your old site into new WordPress pages. WP Beginner has a great free video series for you to understand the basics of WordPress: You have to give them your email, but that’s all. As you work on your new site, you will view all the pages from the subdirectory (don’t worry – this will be temporary). Also, go to Settings > Permalinks and choose Postname as the permalink setting. This will make all your URLs be “pretty” and use words instead of numbers.

      3 – Make a list of all your old (static HTML site) URLs in a Word doc or Excel spreadsheet or Google doc.

      4 – After you feel confident that your new WordPress site is what you want it to be, you can use the process I’ve outlined in this post to go live with the new site. You should place all your old html files (including the old index.html) inside a folder in the public_html folder so they don’t interfere with WordPress. You can download and then delete this folder once you are sure the whole process went fine.

      Make sure all your pages now display from the root. You may need to modify any internal hyperlinks you created.

      WordPress will still live inside the subdirectory, but all the pages and posts will have URLs from the root directory. Your uploaded images and documents will show the subdirectory in their URLs, and that’s okay, because the wp-content > uploads folder where they are will always live in that subdirectory.

      5 – Install the Redirection plugin for WordPress Using this plugin, you can quickly and easily add each URL you made note of in step 3 above to the Source URL field and enter the NEW WordPress URL in the Target URL field. This automatically creates a 301 redirect! Super simple! You do NOT need to do any funky things in .htaccess to make this happen. This plugin creates all the redirects for you. All you need to know is the old url and the new url. By doing this, you will retain all the SEO value of these pages. Their SEO value will be applied to the new page.

      I am available for hourly help if needed or just write back here.

      • Hi Angela,

        You are a complete legend! Thank you so much for taking the time out to map these steps out, it really means a lot.

        I’ve already started with the sub-directory installation as per your instructions and will start copying over the content next.

        Really excited to get this site over and be able to update it more easily.

        One other thing that is niggling me. Is there anything special I need to do in terms of the home page and bringing this over into WP? I keep seeing the terms index.html, index.php, home.php etc. I know you can set a static page within WP. Just want to make sure I do that correctly

        Also, should the old content coming over be built as posts or pages within WP….. or is this just personal choice?

        Thanks again for all your help on this!


        • Hi Stephen,

          That’s awesome!!!

          The main WordPress index.php file is basically what drives WordPress as a whole and isn’t related to your home page per se. The contents of the WordPress index.php file points to the WordPress installation, and then WordPress takes everything from there.

          What this all means for you is that when you go live, you will follow the process I outlined which involves putting a COPY of the index.php file that is in your WordPress directory (which you have in a subdirectory right now) and editing a line in that file that lets WordPress know that your WP application is in the subdirectory. That’s all.

          In the public_html file when you go live, you’ll just have the following:

          cgi-bin (which is a folder on most hosting accounts)
          index.php (which is the copy of the index.php file from WP edited per the instructions in my post).
          old (which will be a folder you’ll create to put all your static HTML files)
          subdirectory (the folder that you WordPress install is in)

          That’s usually it!

          So, keep working on your WP site, and then reach out when you are ready to go live.

          As for pages versus posts, pages are typically more static content: about us, services, contact, etc.

          Posts are usually news or timely items: press releases, announcements, events, etc.

          I imagine if you had this set up as a static HTML site, most of your content will be pages and maybe pages with subpages.

          Good luck!


  36. Thanks for this. I was losing my hair over this and you made it look like a piece of cake. Keep it real.

  37. Hi Angela, thanks for the information here. I think I have a slightly different twist on this problem. I have WP installed in the larsonfamilymortuary subdirectory on the site and do not want to move it. The “live” site currently is on Godaddy, and that site is not a WP site at all. After putting the WP site into order, I want to switch the name servers over to Hostgator and let the world find the new WP site.

    I have already set up an add-on domain in Hostgator pointing to that directory.
    Is the rest of it as simple as just changing the Site Address URL to

    Seems like there should be more to it.

    Thanks for any comments.


    • Hi Joe,

      Yes, if you add the domain as an add-on domain and point the domain to the subdirectory, you should just have to change the Settings > General to be

      However, you should also use the Velvet Blue URLs plugin to rewrite all the URLs of uploaded images, files, and internal links from the old subdirectory URL to the correct URL.

      Good luck!


      • Thanks for the update Angela. I managed to ignore my own notes and changed the WordPress URL instead of the Site URL, and all the pages disappeared, but a run through with the Velvet Blue tool brought everything back. After that I went back and changed the Site URL like I should have done the first time. Everything is working now and the links all look correct to the end users. Making a note to read my own directions next time. The next project is to copy the whole site over to a secondary folder somewhere so I can have a testing version to play with. For that I’ll go back to your original post and this time follow the directions.

        But thanks again. I appreciate all the great knowledge you give out.


        • Hi Joe,

          For duplicating the site, I highly recommend the Duplicator plugin. You just need to run the plugin to “Package” your site, and it will make a full copy of the database and all the files and zip them up.

          Then, you will download the zip file and the installer script and upload them to the folder where you want to have your staging environment.

          You will visit that folder URL/intaller.php and you’ll be guided through restoring a copy of the site in the subfolder. The only technical thing you need to do is use your web hosting control panel to create a new, blank database using the MySQL Wizard. Take note of the database name, username and password. I should write a blog post about this!

          Good luck!

  38. Thanks so much for writing this. I am getting ready to finally step out of my safety bubble and abandon my iWeb built biz site, which has served me well but it’s time to move on. I have played with WP over the years on various other website ventures but have dreaded the idea of some how cleanly making the switch on my main biz site. Your article has made the impending transition look much less scarry. I do have one question.
    Once I build my new wp site on and follow the steps and make it go live as to replace the iWeb files that currently reside there, when some one visiting my site goes to check source on a page will the code read as…. or will it remain as…. ?
    Thank You!

    • Hi Marta,

      Good for you! You can do it! Sometimes the only way to get confidence is to make mistakes. The only way to learn is from mistakes. You can’t expect to execute perfectly. I learned a lot from breaking things badly. 🙂

      As far as your question about the source code:

      1 – All your post/page URLs will display from the domain root
      2 – All your uploaded images, documents, and PDF URLs will display from the subdirectory – hence why I name my subdirectories professionally, never using the words ‘test’ or ‘dev’ — I often use the initials of the company.
      3 – WordPress still lives in the subdirectory, so you’ll login to the WP dashboard still through the subdirectory.

      Good luck!

Leave a Reply

Your email address will not be published.