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 http://mydomain.com/wordpress 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 is good idea because:

  1. It keeps your root directory clean and tidy (in case you need to add any other PHP applications to your site).
  2. 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 sitename.com/subdirectory/wp-content/uploads/image.jpg, 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.
  3. 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.

“Moving” WordPress from Subdirectory to the Site’s Root Directory

1. Install WordPress as you normally would, but instead of installing it in the root directory (ie in the www or public_html directory), install it in a subdirectory in the www or public_html folder.

Before continuing with this process, YOU MUST DO THE FOLLOWING. DO NOT READ FURTHER UNTIL YOU HAVE READ THESE THINGS:

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 – http://wordpress.org/plugins/wp-db-backup/;

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.

2. Once you’ve completed your design work, adding pages to the site, etc., 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).

3. Next, 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.)

4. 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' );

to

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.

5. 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 http://www.yoursite.com/mywp/wp-login.php.

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, e.g. from http://www.yoursite.com/mywp/post-title/ to http://www.yoursite.compost-title/ 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:

/mywp/%postname%/

 

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

6. 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]

A Note About Using Cforms if WordPress is Installed in a Subdirectory

If you are using Cforms contact form plugin for WordPress, you will need to tell the Cforms javascript that Cforms is in a subdirectory. You’ll want to do this BEFORE you activate the Cforms plugin. Hyperarts.com created a good post about how to do this:

Telling Cforms JS that WordPress is installed in a subdirectory

A Note About Web Hosting

If you have a current site with a non-WordPress friendly host, you may want to set up hosting with a WordPress friendly hosting company and move your current site’s files to the new host and then install WordPress as instructed above.

Problems?

If you have any trouble with this process, please visit my FAQ at: http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/

Please comment on that page.

Success?

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

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

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

  1. 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.

    Themis.

    • 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: https://core.trac.wordpress.org/ticket/17092

  2. 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?

    Thanks

    Stephen

    • 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: http://videos.wpbeginner.com/ 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 https://wordpress.org/plugins/redirection/ 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!

        Stephen

        • 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!

          Angela

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

  4. 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 marinedevcorp.com site and do not want to move it. The “live” larsonfamilymortuary.com 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 http://larsonfamilymortuary.com?

    Seems like there should be more to it.

    Thanks for any comments.

    Joe

    • 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 http://larsonfamilymortuary.com.

      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!

      Angela

      • 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.

        Joe

        • 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!

  5. 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 mysite.com/wp and follow the steps and make it go live as mysite.com 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 mysite.com/…. or will it remain as mysite.com/wp/…. ?
    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!

  6. Hi Angela,

    Thanks for this post: really helpful. I followed this successfully for a website last year.

    However, I am having problems with a new website (which uses a different theme).
    After following your steps, the homepage won’t display correctly – it displays the headings, text, images, links etc but looks as if it’s missing its template or css.

    I can’t figure out what the problem is and have tried various things. The interesting thing is that I can get it to redirect and display correctly my homepage if I leave my wordpress general settings as is but this means the reference to the subdirectory appears. I’ve tried everything I can think of and checked out your FAQs and looked up online.

    I did come across a suggestion by yourself that it might have something to do with the theme files urls. Do you have any suggestions on how to fix this? I may need to do this again with other websites in the future. I’m not sure what to look for in the theme files.

    I would be grateful for any suggestions you may have.

    Thanks

    Ruth

    • Hi Ruth,

      Please comment back with links to screenshots of the following:

      * content of the index.php file in the public_html folder
      * Settings > General page in WordPress
      * the rewrite rules for WordPress in the .htaccess file

      You can upload images at http://postimage.org

      Did you have a caching plugin installed and activated before you did this process? If so, you’ll need to be sure to delete the cache and reset up the caching settings as they need to be updated to work with the new location.

      Angela

        • A couple quick thoughts, capital letters in directory names can be troublesome. I also have been using this line in my index.php file:

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

          And not using the dirname.

          So, it’s best practice to NEVER use CAPs in your directory names and perhaps try the simpler require line.

  7. Thanks so much for the instructions, Angela! Everything worked like a charm except a little issue which I think you’ll be able so help me with very quickly.

    With a .htaccess file in the root directory that has been freshly created through Settings – Permalinks (postname), I am unable to log in to my admin dashboard. However, if I delete the .htaccess file in the root directory (or use the default permalinks setting) I am able to log in to my dashboard.

    All other links and sub-sites work fine, no matter if the .htaccess file exists in root or not. I tried adding the WP-sub-folder (“RewriteBase /wordpress/” and “RewriteRule . /wordpress/index.php [L]”) in the .htaccess file with no luck (dashboard was unreachable again – 404).

    Any clues?

    Thanks so much!

    • Hi Toby,

      The .htaccess should not have /wordpress in the rewrite rule. It should look like this:

      # BEGIN WordPress

      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      # END WordPress

      Delete or rename any other .htaccess files you have in your wordpress folder or public_html folder and make a new blank .htaccess with the above text in it.

      Check for typos in your index.php file. Read the FAQ to this post http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/ as it will help you discover any mistakes.

      Also, check your Settings > General page. Sometimes people put an extra ending / after the WordPress URL. Neither URL should end with a /.

      It will be one of these three things, though I suspect it is a combination of your Settings and wrong info in .htaccess.

        • Thanks Angela for your fast reply!

          I deleted the old .htaccess file in the root folder and replaced it with your text above. Everything works with this method, except the pretty permalinks. As soon as I change the permalinks to %postname% again, WP rewrites the .htaccess file and it is not the same as your text above anymore. I would like to have those pretty permalinks, if possible.

          I checked my index.php file in the root and it has the correct subfolder in the request tag. BUT the request line looks different than yours posted here. Since I am a newbie when it comes to PHP, I’m guessing they do the same thing and WP updated the style of writing the code over time.

          Here is my current require line:
          require( dirname( __FILE__ ) . ‘/wordpress/wp-blog-header.php’ );

          And here is your suggestion on how to write it (obviously changing the ‘mywp’):
          require(‘./mywp/wp-blog-header.php’);?>

          Which require line should I use?

          I also checked the slashes in my Settings > General and they are all fine. In your post you don’t have any “www” but if I only write “http://mywebsite.com” my website can’t be reached at all. So I need to keep the “www” in.

          Any other clues?

          Thanks so incredibly much!

          PS: When I say “root” I am referring to the “public_html” folder, so one instance above the “wordpress” folder.

          • Hi Toby,

            Yes the index.php require line should read:

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

            Be sure the quotes are straight quotes and not curly quotes.

            The fact that it has the dirname in it will cause issues. So, fix that.

            The .htaccess in the public_html folder should not include the subdirectory in it, so you can manually fix that.

            The WordPress URL should be your site name with the www and include the subdirectory with no ending slash.
            The Site URL should be your site name with the www and not include the subdirectory with no ending slash.

            Let me know what happens. Are you on Windows hosting by chance?

  8. I want the site url http://www.saffronmpls.com to go to the wordpress folder http://www.saffronmpls.com/dev
    I get http://www.saffronmpls.com/dev/wp-login.php?redirect_to=http%3A%2F%2Fwww.saffronmpls.com%2Fwp-admin%2F&reauth=1 when I try to login and when I type in http://www.saffronmpls.com I get this:
    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    I have an old flash website I am going to have to turn on by reenabling index.html So you won’t see the error I talk about unless you go to http://www.saffronmpls.com/index.php

  9. Hey Angela :)

    Wow, this is brilliant! I cant tell you just how many times we have created/maintained sites on sub-domains and then preformed a ”full-on’ migration to finish off. Needless to say; your method is much more proficient, and elegant too :)

    The tutorial you posted was extremely simple to follow, yet informative enough to teach us all a very useful lesson (probably the best example of a well thought out topic and post I have seen on the net this year!).

    In-fact I followed the steps with a site I was working on, and it went off without any issues, and I was done within around 20 mins :). There is just one small ‘speed bump’ I am trying to get over;

    it seems the site is not picking up any of the icons (replacing them with squares instead)

    is it possible that I may need to copy a css file over to the route as-well? I am using a custom theme (avada)

    If you dont mind taking a quick “look-see” (www.gridlink.co.za) – and scroll all the way to the footer, you can see an example of the icons replaced by squares, where social networking icons should be.

    you can see the working version on the subdomain (www.v3.gridlink.co.za)

    Any chance you have seen something like this before?

    I look forward to any advice, if possible,

    Thanks so much once again for the epic post, and thanks in advance for any advice to come :)

    Best regards

    Ashton

    • Hi Ashton,

      I work with Avada. Yes, I’ll check this out. I totally see what you’re talking about. I’ll email you back later tonight.

      Angela

      • Hey Angela,

        So sorry for the late reply, I went away for the weekend,

        I really appreciate your response, and will be so so so happy if you have any advice for me to move forward,

        again, thanks for taking the time, I really appreciate it!

        Hoping you have a wonderful day :)

        Kind regards

        Ashton

  10. Dear Angela,

    I have followed your tutorial to the core and am still unable to point my website “ishah.net/wordpress” to “ishah.net”. I installed wordpress through godaddy applications and then followed your instructions as they were.

    When I open the site with /wordpress it opens fine but without it , it goes to a MAINTENANCE page with greyish empty display. I have been working on it using many different tutorials and the result have been the same. On top of everything I couldn’t find the .htcaccess file in FILEZILLA client even with “FORCE SHOW HIDDEN FILES”. Changing the permalinks style didn’t help either.

    Please please please pleaseeeeeeeeee help me with this :(

    • Hi Hassan,

      I’m sure I can help! Can you please email me your me your GoDaddy login and your WordPress login information to my contact form at http://askwpgirl.com/about/

      I have to go to an appointment soon, but I can look at it in about 90 minutes.

      Angela

  11. Hi Angela nice post!
    I would like to know if you can help me out here…
    Here is the situation I have now…

    I have my domain1.com pointing to my subdirectory1 at my hosting. This is my my domain that I want to keep up.
    I have my domain2.com pointing to my subdirectory2 at my same hosting. This is a test domain I have and I installed a new fresh wordpress with a new theme and now it is ready to change for domain1.

    I want to get my new fresh wodrpress at subdirectory2 poiting to mydomain1.com

    What I tried…
    I changed the wp url and site url from the wp subdirectory2 to point to the domain1.com
    I rename the sudirectory1 to another name, and then I renamed subdirectory2 to subdirectory1.
    Results: The site show up… Some link images broken, but the main problem is when I tried to log in at wp-admin.. I loads and gave me a blank page and I cannot acces the admin panel.

    Do you have any clue how I can solve it?

    • Hi Leandro,

      I understand what you are saying, but I think I would need to look at it to see what might be going on, especially with the domain name pointing. It’s possible that those WordPress settings need to be different depending on if the domain is actually pointing to the subdirectory or the root directory. It’s possible those settings needed to just be for the domain1.com instead of domain1.com/subdirecotry1. Or maybe it’s just a typo in the Settings > General.

      Though, it would take looking at how the domain is pointing and what the settings are in phpMyAdmin at this point.

      Shoot me an email with your WP login and web hosting login, and I can take a look this evening:

      http://askwpgirl.com/about/

      Angela

  12. Hi! I’m not too sure how the QnA format works so I’ll just post my question.

    I am working on a wordpress site that was placed in a sub-directory.

    I have managed to make my site appear as if it was located on the root directory (as this article spoke about). However, when I try to access wp-admin, my subfolder name is still appearing (e.g xyz.com/subfolder/wp-admin?blahblah).

    My question is if there is a recommended method (if any), to remove it for the admin pages as well (e.g xyz.com/wp-admin or xyz.com/wp-login instead of xyz.com/subfolder/wp-login).

    I look forward to your response and thank you in advance for any assistance you could provide. =D

    • Hi Adam,

      No problem. Your commenting is a perfect way to ask a question.

      The wp-admin folder is technically still in the subdirectory, hence why you need to access the WordPress Dashboard via the URL that includes the subdirectory.

      The process I’ve outlined is best used for new installations and development environments. It allows you to “go live” with a site installed in a subdirectory without having to do a bunch of URL rewrites of images, uploaded files, settings, etc. (except to hyperlinks to interior pages). I almost always install WordPress in a subdirectory, though this doesn’t work with some premium hosts like WP Engine.

      The benefit to a subdirectory install is that it keeps the root directory clean in case you are hosting other domains on your same shared hosting account and for creating a new site while an older, existing site is still active.

      I typically name my subdirectories something I can live with, like the initials of the company, rather than something embarrassing like “dev” or “test”. This is because 1) We will still need to login via that URL even after go live (making the pages show from the root), and 2) people may see that URL if they view the URLs for any uploaded files, such as images or PDFs, since the wp-content/uploads folder is still in the subdirectory.

      Basically, what this process does is keeps WordPress in the subdirectory but tells WordPress to show the URLs to pages, posts, categories, etc. from the root.

      I hope this helps make sense.

      If you did have a not-so-great subdirectory name that you’d like to be rid of, you can do the following:

      1) Change your Settings > General to use the root URL for each

      2) Move ALL of your WordPress files to the root

      3) Login to WordPress and install the Velvet Blue URLs plugin https://wordpress.org/plugins/velvet-blues-update-urls/ and rewrite ALL your URLs from the old URL to the new URL. You may also have to check your Theme Options and Sliders to update links to uploaded images in those interfaces.

      So, it can be half a dozen one, six of the other. The process I’ve outlined is quick and pretty easy. Moving the whole WP install to the root requires the extra step of using the Velvet Blues Update URLs plugin and checking to be sure nothing is still linking to the subfolder URL.

      Let me know if you have any other questions, Adam! I’m happy to help clarify, and I’ll update my blog post as needed.

      Angela

      • Hi! Thank you so much for your response.

        It has helped me better understand how to beautify my site’s url and the logic behind it and I am extremely grateful for your aid.

        Have a great week ahead. =D

  13. Hi,

    I have been searching on the internet to find the solution of and issue, and end up here.Hope this is the right place.

    I want to create a page inside another page subdirectory. eg:
    xyz.com/sports/football.

    I have created the sports page and its url is “xyz.com/sports”.
    The problem comes when i want to create football page inside the sports page subdirectory.
    It changes the Permanent link “xyz.com/sports/football” to xyz.com/sportsfootball.
    I tried editing the permanent link but it dont allow me.

    Pls help, i’m already behind the schedule :( :(

    Thanks

    • Hi Sumit,

      I think what you might want to try is to go to Pages > Add New. Create your new page called football. On that page, choose Sports as the Parent Page under Page Attributes on the right side of the screen. Please tell me if that works!

      Angela

      • Hi Angela,

        Thank you for the lightning fast reply, really appreciate it.

        Coming back to the issue, i have just checked page attribute. it has only two dropdown options first is (no parent) or about page. No other option is available here at the moment.

        Thanks
        Sumit

        • Okay. Do you have a page called Sports on your site anywhere? You could create the Sports page then create the football page and choose sports as the parent?

          • Hi Angela,

            I have noticed a really strange problem here. No matter how many page i create, the Parent dropdown in page attribute shows only About page no other page is listed in dropdown. Is there any setting that i need to change. I’m new to wordpress so this might be a silly question. Can you pls help me out here.

            Thanks,
            Sumit

          • Thanks.. I just figure out that cause of this problem, Actually the page were not published yet(Scheduled to be published on May). That is why they were not visible in that option.
            Have a good day :)

          • Yes! I really disklike that feature because I often am creating pages in advance and want to be able to choose the parent page ahead of time before I publish them all.

  14. Any problems with updating WordPress core after doing this? Everything worked well while moving to the root but now I am nervous.

    Thanks!!

  15. Hi there Angela

    This was very helpful, all worked great. However…
    When upgrading to the latest version of WP and/or the latest version of the theme we’re using, we seem to have lost the admin bar when logged in, viewing the site. Also have noticed that when I go to ‘Appearance’ and ‘Customize’, that it gives me a ‘Session has expired’ message and the log-in dialogue. In looking around, the number one solution seems to be to make sure the site address and WordPress URL are the same. However, this doesn’t help with our WP install not being in root. Would you happen to have any ideas on this problem?

    Many thanks for your great site!

    Carl…

    • Hi Carl,

      Yes, this is very typical, so I will add it to my FAQ.

      This is caused by an old session cookie active in your browser. Simply delete you browser cookies and clear your browser cache, then re-login to the site.

      Let me know if that fixes it!

      Angela

      • Hmmm, no luck I’m afraid.

        Since first reaching out to you, I’ve tried deleting cookies and clearing the cache, different browsers, overwriting WordPress core files through FTP, and contacting the theme creators. Still no luck. It still basically is still seeing me as logged out when viewing any part of my live site, while logged in.

        I do remember this happening once before when I was developing a different site, and it was also when the site was not in root, with the ‘WordPress Address’ having the ‘/wp’ appended. The only thing I can find by searching, is people also mentioning to make sure the WordPress Address and Site Address match, which doesn’t help in this case, as our WP install is in that /wp folder on the server.

        I wonder if you might have any other clues?

        Thanks again!

        Carl…

        • I think there may be a typo somewhere, as I do this process on every site I’ve set up, and I’ve only seen the problem if something is incorrect some place. Here’s what I would do. This wouldn’t be related to your WP or theme install.

          Reply to me with screenshots using http://postimage.org/ of:

          1 – Screenshot the contents of the index.php file in your root.
          2 – Delete the .htaccess file in your subdirectory and send a screenshot of the .htaccess file in your root (first go to Settings > Permalinks and click Save Changes).
          3 – Screenshot of your Settings > General page.

          Sometimes people put an additional . or / somewhere that can really mess things up.

        • So, when you say it’s seeing you as logged out, do you mean you can’t see the admin bar? Have you tried checking your User Settings to be sure Show Toolbar when viewing site is checked?

          • Yep, can’t see the admin bar, but also when going to ‘Appearance’ and ‘Customize’ it continuously asks me to log in and shows the WordPress login screen. (Even though I’m logged in.) Actually one other thing that happens, is that when I’m my theme options, it keeps telling me that ‘Settings have changed, you should save them’, when I’ve done nothing at all. Guess it’s all related in some way.

            That box is definitely ticked. I’ll work through the other stuff above, and get back to you soon. Everything was working perfectly til I upgraded to the latest version of WP through the WP dashboard, so I guess something could have gone awry during that process?

            Thanks!

        • However, I do think the issue is related to a typo in your index.php file in the root (public_html) directory. I think perhaps you have /wp/wp twice and that is the problem.

          Here’s what your index.php file should look like:

          http://postimg.org/image/4uxn0tyud/

          So, I am highly suspicious that this file of yours is not looking like this and you have an extra wp on the require line or some other typo. How I know this is that I know what parent theme you are using for your site as I use the same theme a lot and that if I try to go to the stylesheet for that theme, I get this error:

          http://postimg.org/image/4sjhgc9qf/

          • Yes, your line is not correct. It should look like this:


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

            The problem is with your index.php file, Carl. It should not contain the dirname in it. If it has the dirname in it, then it needs to not have the /wp/ — but you should just change it to what I sent to you. Then, delete your cache and cookies and test again.

            I do this every day, so I know 100% this is your problem.

          • Bingo!

            Just had to clear/purge my caches after the changes, and there you go. Fixed! That’s why they pay you the big bucks. 😉

            Do you know have any idea why it would have been fine until the WP upgrade? Now that it’s changed, do you think it’s likely to happen again/change back? (If it does, at least I’ll know one thing to watch out for!)

            Thanks so much, again, for your time! You’ve helped cure that major headache for us. :)

            Carl…

          • I think it was a coincidence. That extra code you had in there was causing the directory to output twice. WordPress never overwrites that file on upgrade.

  16. Hi, greate article.
    Just one problem: following this guide my website “front-end” now points to the “root” (like “example.com”), which is fine. But the back-end still has an URL like “example.com/test/wp-admin/…”.
    Is it possible to get rid of “/test/” part of the URL?

    Thanks in advance

    • Hi Stephane, Great question. Actually, no, you will not get rid of that in the URL because WordPress is still in this subdirectory, hence WordPress and all the uploaded images and files will be referenced by way of this URL. I am fine with this and it’s totally okay for that to be the case, but if it annoys you, you can do the following:

      1 – Change your Settings > General to use the root URL for both the WordPress URL and Site URL

      2 – MOVE ALL of the files out of the subdirectory to the root directory.

      3 – Log into WordPress via the root.

      4 – Install the Velvet Blue URLs plugin https://wordpress.org/plugins/velvet-blues-update-urls/ and use it to rewrite all the old URLs for all the uploaded files to use the new root URL.

  17. Great article, i tried to follow your steps but got stuck at Step No. 2
    I don’t see WordPress address (URL) & Site Address (URL) blocks available under , Settings -> General.
    I have the WP-MU version 4.1.1 installed at http://www.site1.com/wp_install1
    And site is accessible with this url but now, i want to remove “/wp_install1″ from the url for user.

    This is may be because I have WordPress multi site enabled and i need to handle step2 differently when wordpress is enable for MU/multisite. Just my guess.
    Any ideas suggestion is welcome, as i am really stuck on this issue.
    Thanks is advance for your help.

    • Hi DashDo, I don’t have instructions here for multi-site. I’m sorry. I think that is a real conundrum. As far as I know, you can’t run multisite from a subdirectory.

  18. Hi Angela-
    Does it matter that the Google-site-verification html document they have you upload to your server to verify Webmaster Tools (or is it Analytics??) still resides on the original root directory?
    I was in the File Manager tonight of a client website that I have used this subdirectory/root directory move on and noticed that. Should I move it to the subdirectory folder that WP now resides in?

    Thanks for all the effort you put into this page.

    • Hi Jennifer,

      That is a very good question. The Google Site Verification is used for Google Webmaster Tools. That needs to be in the public_html directory of the site, so, yes, move it to the root. Then, login to Google Webmaster Tools and make sure it’s working okay.

      As far as Google Analytics goes, that code usually inserted via a theme option, a Google Analytics plugin, and SEO plugin, or manually hard coded in your footer.php file. You will need to check your Google Analytics settings at Google. You can view your page source and make sure you see a code starting with UA- somewhere in your page source. Then, make sure you are still getting stats reporting for the new URLs.

      You do need to be careful with your page rank and do 301 redirects on the old pages/posts to the new ones if you did this for a site that’s been for while.

  19. Hi,

    This article helped me so much! Thank you for posting it!

    I have one thing I am unsure about, though: for security purposes – what is best: keeping the .htaccess only in the subfolder or only in the root? (or in both?)

    • Hi Ami,

      The purpose of the .htaccess file in this case is to allow Apache to rewrite the URLs. Usually this works best from the root. There are other purposes for .htaccess such as protecting directories. I teach a security class, and my experience has been that when I teach people how to modify .htaccess files to protect their website, they often end up breaking things. So, I typically recommend using a plugin like the Sucuri plugin plus their firewall service. I think that will give you the best protection in the long run.

      Angela

      • Hi Angela,

        Thank you for your answer. Yes, I am considering Sucuri. But I am trying to also follow best practices with anything else I can do.

        Actually, not having a .htaccess in public_html caused errors when clicking on pages from the menu so it seems that I need one there. But, in this case, is it ok to delete the .htaccess from the subfolder? Or should I leave it there? (It seems there’s no change if I delete it.)

        • Usually .htaccess works best from the directory where the URLs are served from, in other words, the root directory. You can delete the .htaccess file in your subdirectory. Login to WordPress and go to Settings > Permalinks and click Save Changes. This will generate a new .htaccess file in the root directory.

  20. I was strugling with a WordPress installation on a Synology NAS (which doesn’t seem to be a standard WordPress environment) but this perfectly solved my problem.

    Thank you!

  21. Thanks so much for this post, I’ve completed the steps but once i log back into wordpress and make changes to the theme, css, etc. some of the ccs files associated move back to the old sub directory and stop the website from rendering properly. Do you know what could be causing this?

    • Hi Hayley,

      In this process, the WordPress files, theme files, etc., do not MOVE. They stay in the subdirectory. That’s the point. You don’t have to move the WordPress installation in order for the URLs for the pages/posts to show from the root of the site.

      The website should display fine. Do you have a URL that you can send to me?

      Angela

  22. Hello,
    Thanks for your tutorial. I’ve got a onepage site and this doesnt seem to work for me. Is there anyway you could help pls?
    Thanks.

    • Hi Kerrion,

      Yes, please let me know what your website is. Sometimes themes can cause problems if they aren’t coded correctly, but this process usually works for good themes. You might need to manually update some of the links in your one-page site navigation.

      Angela

    • Hi Martin,

      I’m glad that worked! Let me know if you have any questions about anything. Hopefully, no migration will take 8-10 hours. I do know a lot of tricks for moving the WordPress install, but this process is a lot more efficient. :-)

      Angela

  23. THANK YOU FOR THIS ARTICLE!! It actually EXPLAINED things well and you pinpointed what people usually do by mistake. After about 4 attempts to follow other people’s directions, this finally made it work! Can I suggest one edit that seems like a no-brainer, but I think should be added though? You should maybe type in that they need to click “SAVE SETTINGS” after they edit the URL, and mention how to edit the already uploaded file without having to reupload it. I figured out that I had to go into my GoDaddy cPanel interface and edit it through the file manager, but not everyone will figure it out on their own. :) Anyway, thanks so much again!

  24. Not exactly a question on the move topic, but about multi-site Worpress and some odd behavior and I thought you may have the answer given your background with WP. I have a multi-site setup on a deluxe server plan (working just fine until currently). The new issue is that when I try to host another WP site on the plan separate from the multi-site setup it will not let me install WP!? After searching the internet I can not find an answer to this question.

    Apologies for the derail, Angela
    Thank you

    • Hi Rick,

      Thanks for writing. I love to be derailed! I’m always up for a puzzle. Here’s what I would try:

      1) Go into your web hosting control panel and set up an add-on domain for the new WP site. It should have it’s own URL that is distinct from the URL related to your multi-site. It should get it’s own subdirectory within your public_html folder, like myawesomenewsite

      2) Instead of using one of the auto installers at your web host, manually install WordPress. To do this, download the WordPress package from wordpress.org. Unzip it and FTP the files to the myawesomenewsite directory.

      3) In the web hosting control panel, use the Database Wizard to create a new, blank database and username. Take note of the database name, database location (usually localhost), username, and password.

      4) Rename the wp-config-sample.php file in the myawesomenewsite directory to wp-config.php and then enter the information into it from Step 3. Also, be sure to set your encryption salts.

      5) Visit myawesomenewsite.com and you should get the auto installer for WordPress. Then, you’ll be done.

      Let me know if this works. Steps 2-5 are documented more thoroughly at WordPress.org under the “famous 5-minute install”

      After doing Step 1, you will need to make sure that this domain is pointed to your hosting account, and it may take 20 minutes to 2 hours to see the DNS propagation. Contact me at my website About page if you are still stuck.

      • Angela,
        Thank you for your quick response.
        I do everything in your list except for number 1.
        I setup a sub directory, but not use a separate URL to start the auto installer.
        Not using root/myawesomenewsite to start the installer just may be the key.
        I will let you know.
        Thank you

        • Yes, I think with multi-site, basically, the main URL ends up being dedicated to the multi-site installation for the purposes of domain name management.

          So, you should register a different domain name, and add that as an “add-on” domain in its own folder, then you should be able to install WordPress to that domain.

  25. Hi Angela
    Sorry if this is a repeat question I tried to read through the blog but so many different aspect my mind boggled. :(
    I have used the installtron clone feature to clone my sisters site to fix the issue of subdirectory installation. My question is once you clone a site can you safely remove the original installation. Will the clone be independant of it.
    Thanks for your amazing site and your patience.
    Katrena

    • Hi Katrena,

      I’m not familiar with Installatron, so I can’t say how the cloning feature works. However, the two important things are that you have a full copy of the wp-content folder as well as a backup of the database. The database is NOT a file. It is on the server and requires that you export it and re-import it into a new database. If the site is going to remain on the SAME server, then what you need to do is copy the wp-config.php file from the original installation as that contains all the database settings. You may also need to go into database via phpMyAdmin.

      However, perhaps you have taken care of all this already. If the new installation is working, then you could try putting the old installation in a folder called _OLD. If the new site still works, then you don’t need that old installation any longer.

      Good Luck!

  26. Dear all,

    I have been struggling with getting the site on my domain name. It still works on systemfix.nl/wordpress. I want it to work on systemfix.nl

    If I go to systemfix.nl/wordpress the site loads:

    http://i.imgur.com/OYNh0I6.jpg

    Settings in the SQL database are:

    http://i.imgur.com/dvyvnPU.jpg

    Dashboard general settings:

    http://i.imgur.com/q7lm8Qk.jpg

    When I go to systemfix.nl get this error:

    http://i.imgur.com/dXRsxWe.jpg

    My WordPress folder is in the public_html folder, one level up there is my index.php and .htaccess, I don’t have a clue anymore. Would be very happy if somebody helps me out.

    • The index.php file and .htaccess files must be in the public_html folder. Everything else you sent looks fine. Let me know if you are still having trouble.

    • Dear Angela,
      I’m afraid I have created a huge chaos while trying to move my new site from the subdomain to the root folder :( I have very (close to 0) experience in web developing, so I was trying to follow my webhoster’s instructions to the letter, but something must have gone wrong in the process..
      I had created a subdomain NEW under my Root folder, where I installed the WordPress and created a lovely new site that I was very proud about.
      This morning, again as per webhoster’s instructions, I copied the index.php file under root and changed it to (‘./new/wp-blog-header.php’)
      i was also supposed to copy across the .htaccess file, but I didn’t have it for some reason under my new site, co I created it there, copied across under root and gave it 0777 permissions.
      After that, in my new site WP dashboard, under Settings/General, I changed the address of the site, deleting the /NEW – by mistake however i deleted the /New from both lines (WordPress and Site Adress).
      And after that it’s pure chaos :(
      My old site isn’t working anymore (unless I restore it with the backup)
      I receive the following error message: Warning: require(/home/www/53aedd3d537f83614fabcd48dff17fef/web./new/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home/www/53aedd3d537f83614fabcd48dff17fef/web/index.php on line 17

      Fatal error: require() [function.require]: Failed opening required ‘/home/www/53aedd3d537f83614fabcd48dff17fef/web./new/wp-blog-header.php’ (include_path=’.:/opt/php/lib/php’) in /home/www/53aedd3d537f83614fabcd48dff17fef/web/index.php on line 17

      And my new site with the /new/ extension shows only a very badly formatted homepage, whereas all the links from there point to the error message above.
      I’ve tried to restore everything from backup, but unfortunately it only works for the old site, whereas I can’t get into the admin panel of the new site to change anything at all anymore.
      My webhoster wasn’t too much of help, they said basically that they are not developers and that I should solve this with a webmaster or try to find solution with the WP community. Or that I should try to have a clear install of the WP under the root, because I ‘probably installed it wrongly’. But my main worry is that – has all work that I had done on the new site disappeared now??
      Please help, you’re my last hope :(

  27. Hello Angela,

    My WP installation is still located in a /blog/mysite.com folder even if it does not appear in the main Url (thanks to your help last year, and to the present article).
    But my painter website is both in French and in English which is not so great for SEO, so I would like to change it into a multisite installation with the actual Url staying in English and another new domain dedicated to the French version.
    I found somewhere that for this kind of configuration the first WP installation should NOT be located in a /blog/ folder but in the root.
    Do you confirm? And in this case what should be the best solution?
    And besides, could you tell me about a simple and clear tutorial that would explain step after step how to create the multisite installation (I did not find it here)?
    Many thanks for your help!
    Hazlo

    • Hi Hazlo,

      Here is how I have handled multi-language sites: I use a plugin called WordPress Multi-Lingual. It can be found at http://wpml.org/

      What it does is automatically create a URL for each language. I am using it at http://bcap.org. Click En Espanol in the upper-right corner of the page.

      The plugin allows you to have one WordPress installation that manages the content in multiple languages, so each page of your site will have an English and a French version. It works primarily as a content management system for your various language pages, so you have two versions of each page. You can choose which pages you want to display in French and which not.

      It does not matter if you have the WordPress install in a subdirectory, because the different translations URLs are managed via the .htaccess file. Since you would have only one install of WordPress, then it is fine.

      Please check out the plugin. It is very worth the cost! You do NOT need to create Multisite for this!!! The plugin handles the URLs without having a multi-site installation, so it is much simpler.

      Angela

      • Thanks Angela for your quick reply!
        So then it is MultiLingual Plugin vs Multisite installation.
        I looked at http://bcap.org and I could see that it works very good.
        On the other hand, the Url is getting sometimes a bit long (for instance /es/about-us-es/contacto/ ) and then I wondered about the impact it can have or not, on SEO.
        But you are right, in my case and with my limited knowledge about development, it must be a much easier way to choose the plugin way!
        I will check it.
        Thank you again.
        Hazlo

        • Yes, the URL has one more segment for the language, but otherwise is the same as the main site. I don’t think this makes much difference between subdomains or subdirectories as with multisite, you would have to do one or the other anyway.

          But, I do think that the WPML plugin might be more SEO friendly anyway. Please read their documentation on multi-lingual SEO:

          http://wpml.org/2013/07/how-to-do-multilingual-seo-for-wordpress-sites/

          It is helpful to use themes and plugins that work well with WPML. Most good plugin and theme developers will explicitly indicate that they work with WPML.

    • Hi Ali,

      That is unusual. What is your actual URL? Is it working, yet? You can contact your web host and find out if you have your domain name pointed correctly to their servers.

  28. Your method is genius, congrats! Here’s what happened after moving the site url.
    After login in the admin section and trying to connect to some pages or plugins I get “504 Gateway Timeout”.

    I can connect to “wp-admin” but after that, I cannot access any of the menu-> articles, pages, setting, plugins, etc.. because it takes too long…

    What can this be? What I’ve missed?

    Thank you! :-)

    • Hi Daniel,

      Wow! I’m not sure what happened. You will still login via the subdirectory URL /wp-admin, so mysite.com/subdirectory/wp-admin.

      Be sure you don’t have a typo in the index.php and that your Settings > General are correct. Read the original instructions carefully and the FAQ. I think you do have a typo somewhere.

      • I’ve found out the problem. In the index.php I had an additional slash “/” before “wp-bolg-header.php”, after removing it everything works normally.

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

        Thanks!

        • So, you usually do need a / in that line, but it needs to have the subdirectory name:

          require( dirname( __FILE__ ) . ‘/subdirectoryname/wp-blog-header.php’ );

          • Hi Angela!

            Any idea why wordpress continues to use the links for files (pdf, jpg) without the subdirectory?

            Example:

            /wp-content/uploads/2014/10/FILE.pdf

            instead of

            /mywp/wp-content/uploads/2014/10/FILE.pdf

            Thank you!

          • Because WordPress is installed in the subdirectory, it will always use the subdirectory in the URL for all uploaded files. However, pages and posts will use the root URL, because that is where we told it to show those from. But for uploaded files, if you look at your FTP directory, you will see that we did NOT MOVE WordPress at all, so, of course, those are in the subdirectory in the wp-content/uploads folder. This is correct, and you don’t have to do anything about it. Sorry for the late response.

  29. Hi, i already have an existing old site in root, and my new site is on /wordpress directory (i can’t access the wp-admin of the old site anymore, just the new one, via mysite.com/wordpress/wp-admin). If i try to copy the index.php of my new site (/wordpress) to root will have any issues or conflicts between the archives? (Because on root, my old site has .htacess with permalinks structure and other archives too). Or it’s better delete my old site to move the new one to root?

    • Hi Nicolle,

      Sorry for the late response. For some reason, I am only now seeing this comment. You cannot have two sites running from the same directory. You cannot have two index.php files in the same directory, so you can’t keep your old site and new site running from the root. You would have to MOVE your old site to another directory and redo the settings and all the hyperlinks, etc. to work from another directory. http://codex.wordpress.org/Moving_WordPress

  30. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some time and was hoping
    maybe you would have some experience with something
    like this. Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

  31. I tried this approach of moving the site into a sub-directory and I couldn’t preview any pages or posts. I got an error message “You do not have permission to preview drafts”.

    There has been much written about this (see https://www.google.co.uk/search?q=You+do+not+have+permission+to+preview+drafts)

    Basically WordPress thinks you are not logged in because the user is logged into a WordPress installation at

    http://your-domain/your-subdirectory/

    but the preview appears to be viewed at

    http://your-domain/?preview=true&preview_id=107&preview_nonce=87b218b886

    (these numbers will be different in your case)

    I suggest that if your host allows it, a better approach (at least the one I am now using) is to use sub-domains and map each domain or sub-domains to a directory of your choice on the server. For example

    http://example.com -> /home/username//websites/old/working-copy-of-the-old-website

    I have also mapped

    http://old.example.com -> /home/username//websites/old/working-copy-of-the-old-website

    This is so I can hide my development work from the public and the old website continues to work at the expected address. Also, there will be an archive of the old website for my customer when I am done.

    http://dev.example.com -> /home/username/websites/my-wordpress-directory

    Once I am ready to go public, I will re-map as follows

    http://example.com -> /home/username/websites/my-wordpress-directory

    There is another step: I will need to update the site and home urls as already described. I have also found I need to update the links in my posts, such as links to graphics. I found this web page very helpful to do all this http://www.onextrapixel.com/2010/01/30/13-useful-wordpress-sql-queries-you-wish-you-knew-earlier/

    • The procedure I have written about works flawlessly and much easier, better than what you are describing using subdomains, because you don’t have to update any graphics links or other links to assets on the site.

      The reason you are getting the permissions error is that you need to clear your browser cache and re-login into the site.

    • Sorry for the delayed response. Can you give me more information about your image path and where it was original and which file is referencing it? With my process, you should need to change the path to any images uploaded via the media library.

  32. Just a little update for this procedure with a new 2014 Synology 214play NAS:

    If you’re using a purchased domain name or DDNS name, login to your NAS using this address.
    Install the MariaDB MySQL database, phpMyAdmin utility and finally WordPress in that order; installing WordPress when logged-in with your domain name will configure WordPress with the site domain name rather than an IP address.
    I received a Directory Could Not Be Created error when attempting to change the site address. I changed this using phpMyAdmin, logged-in as root. I changed the WordPressBlog table, wp_options entry to the site root address, i.e., change it from /wordpress to . This change was only picked-up when I Stopped and Started the WordPress process in the Synology Package Centre app.
    Finally you will not need to edit the line in the index.php file as this uses an absolute reference on the disk, require(‘/var/services/web/wordpress/wp-blog-header.php’);.

    Thank you for the advice here, much appreciated. :)

  33. I am a regular reader and have learned a lot from your most comprehensive, honest and generous articles on WordPress and related issues. Thanks a lot for all this.

  34. Hi Angela,

    I was following your steps but must have done something wrong. I could not get back into wordpress. I made it through step 1 and now when I try to access anything I just get url not found or 404 error. I cannot access the new wordpress site to change the url. Can you help? Any suggestions? Thanks! -(My new wordpress site is in a subdirectory called groundworknola.org/sample2 and I was trying to take down the old site to replace it with this one.)

    • Alicia, I wasn’t getting notifications on comments to my site for some reason, so I’m sorry for the delayed response. Did you get your issue worked out? After Step 1, you will not be able to login to your site until you proceed to the next steps.

  35. An update for you because I got it all to work!

    Oddly enough it absolutely IS possible to create a static blog page with the slug /blog even when your WP install resides in a folder called /blog. There is no clash! I wasn’t expecting this (as I gather you weren’t either!) but I tested it on a test site yesterday and pushed it to my site this morning.

    My site is now switched over so you can see that this does work. My WP install is in the folder /blog but you can view the site on http://www.dancarrphotography.com

    I then created a page with the slug of /blog and set that in the reading settings as the static posts page. Visible at dancarrphotography.com/blog

    I then added /blog to the permalink structure and everything works perfectly! All my image SEO is preserved and all my blog backlinks work as well as any previous back links that went directly to dancarrphotography.com/blog.

    Amazing! Thanks for your help while I tried to figure all this out.

    • Yay! I’m so glad you tried that, and it worked!!! I thought I had tried it in the past, and it did weird things. The way permalinks are handled has changed for the better in recent versions of WordPress, so that is great news!!! I’ll write up something for the FAQ page on using this solution as an answer for preserving SEO on sites that have a nice URL (like blog) but just want their static pages to show up without the /blog in them. Thanks!

      • Brilliant, yes I’m sure people will be interested in this. I read in many places that this would not work, probably used to be the case, but now it certainly does seem to work fine :)

  36. Thank you so much for the post, I’m going to work in a personal website and I was looking for the way to do it in the background, without visitors seeing the process. :)

    • Hi, you can do this a couple ways:

      1 – If there is an existing site, install WordPress in a subdirectory and install a “Coming Soon” or “Under Construction” plugin to make sure no one can see the site.

      2 – If there is no existing site, then install WordPress in the main public_html directory and install a “Coming Soon” or “Under Construction” plugin to make sure no one can see the site.

      When you are ready to go live, if you have installed the site in a subdirectory, you can follow my instructions at http://askwpgirl.com/how-do-i-move-wordpress-from-a-subdirectory-to-the-root-directory/ and turn off the “Coming Soon” or “Under Construction” plugin. If you installed in the public_html directory, then you just need to turn off the “Coming Soon” or “Under Construction” plugin

  37. If your previous blog was a love one and it was mysite.com/blog , once you have moved the site to the root, what will people actually see if they then go to mysite.com/blog?

    I understand adding the folder name to the permalink to keep all the blog post URLs the same as they used to be, but I’m really curious about what would happen to backlink that go directly to mysite.com/blog ?

    • All live blogs are loved blogs, aren’t they. 😉

      Once you do the process I describe, you will no longer see the posts at mysite.com/blog/ – if you add /blog/ to the permalink custom structure, then the posts (not pages) will have the word /blog/ preceeding the post slug, and therefore will not be broken. However, going directly to mysite.com/blog/ will result in a 404 not found page. You can create a page called “blog” and assign that via Reading Settings as your default posts page.

      • Thanks Angela! What would happen if I created a page called blog and then set that as the posts page in the reading section? Would this cause a clash since my files are still residing in a folder called /blog as well?

        • The other option would be to physically MOVE the WordPress installation to the root then do wildcard redirect of all the /blog/ URLs to the root URL. Then, hopefully, you wouldn’t looks your Google ranking for your images as they would all have 301 redirects to the correct images. How long has your site been up?

        • (am posting the next reply up here because for some reason I can’t get the “Reply” button to appear on your last comment)

          The site has been up for about 7 or 8 years I think, and amassed millions of page views and a lot of back links, hence my cautious approach to this move.

          What about this:

          1. I MOVE the entire site to the root. Then I add /blog/ to the permalink structure to keep all the posts back links working correctly (I’d prefer future blog posts to contain /blog as well so that’s fine)

          2. I guess that if I did this, the links to images within my posts would still point to /blog/wp-content/…. so that’s fine… I won’t loose any ranking on those images. (I think this is true and that the links in the posts are not relative to the specified site root?)

          3. I delete everything else from inside the /blog directory, apart from the wp-content/uploads directory which contains all my previous images.

          4. I create a new page called blog on the new site with the slug /blog and then set that as the static posts page in the reading settings. Now that there are no files in the /blog subdirectory (just the wp-content folder) this should not cause a clash anymore I think?

          So this way all my old posts still work correctly and also mysite.com/blog still takes people to the list of blog posts.

          I reapply appreciate your thoughts Angela, you are awesome!!

          • I am glad you were able preserve your current directory structure and NOT have to go through these steps! That is awesome that you were able to keep the site in the “blog” subdirectory and simply including blog in your custom URL structure and create a page called blog and assign that as the default posts page in the Reading Settings. That is the best of all worlds in your case!!! Yay!

  38. Hey Angela, great site. Great post. Still, I’m having problems :/

    My host is web.com, first time I’ve ever used them. When I install WP I am forced (for some reason) to install into a directory and not the root, so only mysitename.com/installdirectory loads when the install is done and mysitename.com just loads to an under construction page. I’ve deleted and re-installed WP multiple times in the last couple days trying fix this issue to ensure there are no other factors causing problems. I feel like I’m real close to fixing this since finding your post, but it’s still not working. When I go to the htdocs folder in my host’s file manager the only thing there is the install directory (wp1) and the index.php that I just moved there as per this post. Should there be more files in the htdocs folder? I feel like something’s missing. Thanks.

    • I had that issue with some hosts, and it’s just a drag. The only way to get around this issue is to do a manual install following the manual installation instructions at WordPress.org. My instructions won’t work in this case, because the host is pointing the WordPress installation to that subdirectory, thus thwarting all your attempts to show it from the root. I see this most often with Network Solutions installations. So, maybe that’s a sign to use a different host.

      • Hi Angela. I am having this issue right now where the client’s hosting company will not allow me to install WordPress on the root level… it is forcing me to install into a subdirectory. I even tried manually installing files on the root via FTP and it all failed.

        Do you know why some hosting providers prohibit this? I want my client to switch hosting companies but they are resisting because they think there is nothing wrong with them and are quite annoyed at the prospect of having to set up a new account somewhere. (Hard to explain techie stuff like this to a client and make them understand :/ ya’ know the feeling I’m sure)

        Is there any way around this? I have clled the current hosting company’s tech support and no one there is even halfway experienced with using wordpress, they have been no help at all.

        • I have seen Network Solutions do this, and it creates a big problem when trying to run WordPress in the root or switching from the subdirectory to the root. If a host will not accommodate WordPress being installed where you need/want it, they are not a good host and are likely to not support WordPress well in general. The way around this is to do the install yourself and not rely on the autoinstaller provided by the host. You will need to follow the instructions at: http://codex.wordpress.org/Installing_WordPress

  39. Hi Angela,

    I have recently used the duplicator plugin to go from one host to another. The domain remains the same. I created a new folder in the destination host’s public_html”

    When I run the duplicator in the subdirectory the site is now “mywebsite.com/folder”
    I would like it to be “mywebsite.com”

    To follow your steps, you require index.php to be copied to the root. What if there is already an index.php there? What if I want to have multiple sites on this host, I cannot have an index.php sitting in the root for 5 different websites.

    On bluehost, I have various domains running from sub directories, however as they were all fresh installs i never had to go through any of this. They all run fine from a subdirectory with no need to change the wordpress admin site address or wordpresss site url settings in.

    Thanks

    • If there already is an index.php file in the root, then check to see what subfolder it is pointing to or what exactly is in that file. It’s possible, the index file is simply there to prevent directory searching of your root folder.

      With most hosting situations, the root folder is reserved for the primary domain. All other domains are installed and pointing to subdirectories, so their index files would typically never display in the root directory. The only index file in the root will be a plaeholder index file to prevent directory listings or the index file for the main domain.

  40. What if my wp is on a subdomain, like wp.example.com? What changes should i make to

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

    • If you install your site in a subdomain, you cannot use my directions for moving it to the root. You need to following the instructions from WordPress.org for actually MOVING the WP install to your root (aka public_html) folder.

  41. You are the best!! Just had a nightmare trying to move my site up to the root folder then saw this article and it all suddenly worked. Thank you!!!

  42. Thanks Angela! I was so scared to move my new site. I spent days “reading” about it all over the web but was scared to actually do it. I followed your instructions (they were by far the clearest I have found) as best I could understand and it went off without a hitch. I especially appreciated you posting the code of the exact index.php file I needed. I found 2 before the right one. The hugest “PHEW!” I have ever sighed!

    One question, since it was originally an html/css site I was going to follow step 6 and make the “silence is golden” index.php file and put it in the wp folder, but it was already there. It was one of the 2 index.php I found when I was looking for the correct one. Why was it already there?

    Thanks again!

    • Hi Susan,

      If people move the index.php out of the subfolder, then you definitely want a Silence is Golden index.php. But, if there is already one there, if for example you copied the index.php file, then you don’t need another one as long as everything fine, and when you visit the site/subfolder you don’t see a directory listing.

  43. I made the mistake of using the subdirectory /wordpress and should have used a less obvious subdirectory as you said. Is there a way of changing the subdirectory?

    Also, my current permalink settings are set to Post Name: site.com/sample-post so if I change to Custom Structure: site.com/wordpress(or new subdirectory)/%postname% – are they the same thing that return the nice title url?

    Thanks for all your guidance- especially reading through all the comments/questions and your help in answering. Mike

  44. Hi Angela,

    Great post, been searching the web for something like this. A couple of questions if I may..:

    – does this method work for WordPress sites running Woocommerce
    – I’m assuming if I don’t enable permalinks on my Dev site and then enable them on my Live site, that I have just made the move a little bit easier?
    Thanks
    Warren

    • I don’t know how friendly WooCommerce is to running in a subdirectory. Theoretically, it should work, but it depends on how WooCommerce refers to the WordPress URL versus the site URL. I’ve seen many themes and plugins that are written incorrectly and use the site URL when they should use the install URL and vice versa. What I would do is test it. Set up a dev environment in a subdirectory of a URL. For testing purposes, you might have to set up a subdomain, such as testing.mywebsite.com and install WordPress inside of testing.mywebsite.com/wootest

      With your site in the wootest subdirectory, add some products, etc., to your WooCommerce site. Then, follow my instructions to have the page and post URLs for the site display at testing.mywebsite.com. Then, try adding products, purchasing, etc. If it works, great! If it doesn’t, you can check with the WooCommerce folks.

      I always enable the permalinks. The permalinks are often necessary for things to work well, though, yes, it saves you step, but also requires you create any internal hyperlinks using the un-SEO friendly ugly URLs. It’s just not that big a deal to update your permalinks after this process by going to Settings > Permalinks and clicking Save Changes.

      • Thanks for the reply Angela, I’ll test it and see and report back..

        One thing though – if Woocommerce references the site URL and WordPress URL the wrong way around, could I get around that by changing them both to the root domain and then moving all the files + folders from my sub-directory?

        • Yes, but all of the URLs to the product images, etc., will be using the subdirectory. You could use the Velvet Blues URLs plugin to rewrite all of these. Hopefully it will catch them all. Again, I’d test and be sure you are comfortable with what it will take to move it all. I often use BackupBuddy plugin for this.

          • thanks for the plugin tips, not starting my woocommerce site for a couple of weeks yet, so will report back the results then

  45. Thank-you, Angela!
    You put english on the Codex’s anti-human wording!
    I followed your instructions and the index page changed to the root address perfectly but the interior pages still had my /andi subdirectory attached. I continued reading your helpful instructions and went in and clicked the Save Changes in the permalinks area and voila! All the pages have now lost the /andi bit. So thanks so much.

    IT TOOK LESS THAN 5 MINUTES TO GET MY SITE UP AND RUNNING AS IF IT WAS INSTALLED IN THE ROOT ALL ALONG THANKS TO YOU.

    Two questions!

    1. Why did simply clicking SAVE CHANGES on the permalinks page (without changing anything on that page) fix the links (remove the /andi subdirectory from the address bar)?

    2. the codex says you need to move the .htaccess file to the root. You say you might have to move the .htaccess file to the root. Where is the .htaccess file if i need to do this in the future for another page? And is that what clicking the Save Changes button on the permalinks page does for you (if it works) such that you only need to move the .htaccess file manually if clicking the Save Changes button doesn’t do that?

    Thanks for making what could have been a nightmare, painless!
    Andi
    ps. this was my first wordpress page. :)

    • Hi Andi,

      Great question. The reason why clicking Save Changes will rewrite the URLs is because WordPress uses the mod rewrite directive on the Apache server to turn the ugly urls with the page ID in it to the “pretty” urls. To do this, WordPress uses the .htaccess file to communicate with the server how exactly to rewrite the URLs based on the settings on the Permalinks page. The general .htaccess command looks like this:


      # BEGIN WordPress

      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      # END WordPress

      If you installed WordPress in a subdirectory, then the .htaccess file might contain the subdirectory name in the rewrite rule. Clicking Save Changes on the Permalinks page after making the other changes per my post instructions forces WordPress to rewrite the .htaccess file.

      .htaccess is a powerful file that can be used to perform a variety of server-level functions – such as blocking access to users, directories, files, etc. There may be multiple .htaccess files on the server in different directories that do different things. However, .htaccess is top-level down, so anything done in the top level .htaccess file will trickle down to subdirectories. If you install WP in a subdirectory to start with, the .htaccess will be in the subdirectory because that is the only place WP knows exists as far as that install is concerned. When you move your index.php file to the root, then the .htaccess in the root directory can and will be used. Sometimes it still works from the subdirectory location, but, yes, it’s best to have it at the root and remove it from the subdirectory, so you don’t have conflicts between the two.

      I hope that helps explain things.

      • Holy, Angela. A great answer. I understand why clicking the update button for Permalinks rewrites the .htaccess file (even though I didn’t understand all of the coding language). It seems, in language us unfortunate non-geeks can understand, it goes like this:

        WordPress tells the .htaccess file to give your post URLs pretty post name endings (drop the long nonsense endings). When you click the Permalink Save Changes button, if we’ve followed your other instructions, the .htaccess file moves to its new home in the top level root directory. Since the top .htaccess file is the commander-in-chief, all other .htaccess files follow his command. And if by chance there is a belligerent .htaccess file underneath, it might be necessary to remove it.

        Thank-you!

  46. I love you!!! Thank you so much for all the help. After days of trying to figure this out thank God I found you. For some reason the side bars on some of the pages are not working but those are easy to redo when I thought I had to redo the whole thing all over. Thanks again and may the happiness that you bring to others may return to you 1000 fold :)

  47. Hi Angela,
    Great post, and very helpful. Still I have one doubt. I’m currently converting an old html site to a wordpress site. WordPress runs in a subdirectory. So I’m busy writing post etc and sometimes making hyperlinks in a post to another post. These links have the subdirectory in them ofcourse.. Only these don’t get changed when I change my permalinks to the root. How do I solve this?

    I hope you know what I mean, my english is not that good. To explain better, my wordpress runs in site.com/wordpress/
    Now I make 2 posts. In the 2nd post I wirte some text with a link to post one site.com/wordpress/post1
    Now my site is finished and I ‘move’ my site to site.com and update the permalinks. The permalink of de post will now be site.com/post1. The problem is that the link in the text of post 2 still point to site.com/wordpress/post1 resulting in a 404
    Whith a few posts is possible to edit this manually, but in my case there will be many. How to solve this? I now how I can work around this problem in .htaccess, but there must be a nicer solutions.., right?

    Best regards,
    Benno

    • I understand what you are saying.

      I use a plugin called Search and Replace. Search on the CONTENT field using this plugin like this:

      a href=”http://site.com/wordpress/
      a href=”http://site.com/

      This will replace all those internal hyerplinks you made to have the correct link when you “move” the site from site.com/wordpress/ to site.com/

  48. Hey everyone Im working on a project to set up a server at my home I do use a hosting company for my main site this is just a toy project for me to get educated at this time so im using a win 7 home premium computer XAMPP 1.8.2 ( the XAMPP 1.8.3 seems to not work for windows) this pack contains
    •Apache 2.4.4
    •MySQL 5.5.32
    •PHP 5.4.19
    •phpMyAdmin 4.0.4
    •FileZilla FTP Server 0.9.41
    •Tomcat 7.0.42 (with mod_proxy_ajp as connector)
    •Strawberry Perl 5.16.3.1 Portable
    •XAMPP Control Panel 3.2.1 (from hackattack142)
    I also installed bitnami for xamp that contains a word press modual (its inbeded in the installer not sure the version)
    so I have 2 questions:
    1: after getting everything installed and set up it seemed that everything was working ok till I set a user account and password and now it wont let me log back in it (rejects the username and password) and also when it loads it comes up with an error saying,

    syntax error configuration files could not be read, then says to check box for errors but none ever appear:

    however that’s not allways the case if it does not show the error it lets me log in strange (thinking maybe a cache issue or something)

    here is the config.inc file

    2: is since im using windows and most use Linux or unix is there a compatibility issue here with word press? I would love to find some better windows info as most post are of course referring to the other systems any good spots for windows users?

  49. I’ve bookmarked this page and referred back to it a few times when launching various WP sites. Just wanted to let you know how simple and useful this explanation is – much appreciated! :) Cheers!

    • If you do this process, then the posts will be referenced from the root of the site. If you want to keep “blog” in the URL to avoid broken links, you can add the word blog to your permalink structure like this after you follow my instructions on this post:


      /blog/%postname%/

    • Is there any way to re-enable the toolbar for admin while running the site from a subdirectory? I like to browse and edit the site with the toolbar at the top, but it obviously stopped working when we updated the index file.

      • Hi David,

        Yes!!! You just need to clear your browser cache and/or make sure any caching plugin you have installed has all its cached files cleared.

  50. Good morning,

    I’m actually having the exact same issue as Rob. The multi-site installation for WordPress version 3.6.1 does not provide a field for WordPress address. As far as I can tell, the multi-site version is also the source of Super Admin (which translates as Network Admin when logged in, and allows you to install multiple sites and access them from the same interface).

    Logged in both as admin (which is network level access) and a separate user I created with administrator rights, when you go to Settings > General, the listed options available on that page, are as follows:

    Site Title
    Tagline
    Email Address
    Timezone
    Date Format
    TIme Format
    Week Starts On

    The only place I’ve found where the WordPress address is even visible, is when logged in at Network level (My Sites > Network Admin > Sites), and the field in question cannot be edited.

    So I went the long way around and followed the steps (that I could), in the sub-directory to root FAQ. And voila, if I use the root address, it loads the index.php. And that is where the success ended. I also am unable to have the permalinks re-written to disclude the sub-directory.

    Moral of the story, it would appear that enough changed in the multi-site installation version of WordPress, to create complications for this process.

    (Of note, I’ve been trying to get this to work, on a test installation of the multi-site version. If you’d like to see what it looks like, this lab version is established solely for that reason. It isn’t a production environment.)

    • Hi Laura,

      That is good to know you are running multi-site. Multisite cannot be installed in a subdirectory then displayed from the root. This is specified in the documentation for multi-site. It must run in a root directory (or the directory where it will be run from), and all the sites need to be built according to the multi-site instructions. Thank you for letting me know that that is why those URL fields are missing. So, yes, my instructions are not applicable with multi-site installations and trying to do subdirectory installs redirected to the root with multi-site installs will not work, obviously, because you can can’t change these settings.

      Angela

      • I have installed as multi-site as well, so this explains not being able to see the URL in General settings. I used Installatron in cPanel to do the installation, and under its Files & Tables tab it has a modifiable Location URL. It also lists the WP files, directories and db tables that are associated with the install. Would changing the subdirectory here be a substitute for step 2 in your instructions?

  51. Hi Angela

    I would like to move a WordPress site out of a subdirectory using the technique outlined above, but when I go to the Settings -> General tab of the site Dashboard there does not appear to be any option to set the WordPress address URL. I am logged in as Super Admin, and am using WordPress 3.6.1.

    Could you please tell me if I am looking in the wrong place, or if I might be able to do this in another way?

    • Hi Rob,

      I don’t know about the role “Super Admin” that isn’t being administered via some other WordPress plugin. There is only “Admin.” I’m curious about your installation of WordPress. It doesn’t sound like a typical installation. I’d have to see what your seeing in order to troubleshoot further. You could send screenshots to me if you contact me via the About page of my website.

      The other way to change the Site Address is to do this via phpMyAdmin which I have documented on this post:

      http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/

      • Hi Angela

        I have just made the site go live using Installatron. It was unbelievably easy, all I had to do was to use Installatron’s Clone function to copy the file from the subdirectory to root. Installatron managed all of the internal link updates seamlessly. I’m not sure whether it is possible to retrospectively use it on a site that was not originally installed through Installatron though.

        • Yes, you can do the same thing with other plugins like BackupBuddy. BackupBuddy has a script that will rewrite all the necessary URLs on the site without messing up any theme options, etc., which is what you generally worry about in doing any sort of global search and replace. However, I do like installing WP in a subdirectory on purpose for the sake of keeping the root directory clean in case other sites are installed on the same account, and the process is much quicker. Thanks for sharing about Installatron.

  52. Hi
    Thank u so much for this great information. I did move my site to a subdirectory and i think i messed all my links and i can’t login to WordPress anymore to fix the main link in general. Please advise me what should i do in this case? the website is indigitube.tv and it looks messed up. Thank u for taking the time to help me.

  53. Hello Angela,
    Am using wordpress, am getting some problem while changing the permalinks the website will be crashing can you tell me the other option to change the permalinks.

    • Wow. I’ve never experienced WordPress crashing when changing the permalinks. What is your website? I’m not sure how to help you without logging in and seeing the problem. You can contact me via my About page on this website.

  54. Angela-
    I have successfully redirected my photography wordpress test site from the subdirectory to the main url but now the NextGen Pro plugin is not recognizing the correct path to the images… all the galleries have broken file paths.

    WHen I go into each individual gallery, the images are all there but the path is showing the original url instead of the subdirectory url they are actually in. The field is not editable either, so I can’t update it… also cannot find any documentation on Next Gen site!

    Do you have any experience in changing the path to the images in each individual gallery?

    This is the PRO version, but I uninstalled the PRO plugin from the test site, re-downloaded another plugin from my member area, then re-installed the PRO plugin on the real site url. The galleries are still not recognizing the correct paths to the images.

    I’ve put in a support ticket to NextGen, but thought you might have done this before.

    • Hi Jennifer,

      Wow! That’s a new one on me. I think the way the new NextGEN Gallery is working, it might be generating a code that does not update automatically when the site changes. The new way it’s handling galleries is kind of confusing.

      I’d be happy to help you at no charge, because I teach a class on NextGEN Gallery and would like to help you troubleshoot this issue. Please contact me via my about page on this site http://askwpgirl.com/about/ and send me a message with your WordPress login. I’m hoping it’s a quick fix.

      Angela

    • Hi Jen, There is a field in the NextGEN settings to the wp-content folder, so perhaps that value needs to be changed to include the subdirectory in the path.

  55. Hi Angela, I am making a wordpress theme page (a paid one). the thing is I installed everything in a sub domain, (test.mydomain.com) how can I put it in the root folder and make everything to work ??? can it be done? thank you

    • Hi Heidi,

      The problem with this set up is that you put it in a subdomain instead of a subdirectory. What I would do is use the plugin called BackupBuddy to backup the full site, then copy the backup zip into the main directory along with BackupBuddy’s importbuddy.php file. You will need to create a new blank database in your website control panel and take note of the database name, database username, and password, then use that when your run the importbuddy.php script. It’s really pretty easy. Let me know if you get stuck. If you purchase BackupBuddy, and you do a lot of installations of WordPress, it’s worth getting the developer’s license:

      http://askwpgirl.com/go/backupbuddy.php

      This is my affiliate link. If you use that, I’d be happy to help you with the migration.

    • The alternative to using BackupBuddy plugin is the following:

      1 – Change the Settings > General to the domain name you want to use, eg mydomain.com

      2 – Move all of the files to the public_html directory for mydomain.com

      3 – You should be able to view the home page and login to WordPress at this point.

      4 – Go to Settings > Permalinks and update the permalinks – this will write a new .htaccess file if needed

      5 – Install the Search and Replace plugin. ONLY search on the website CONTENT, NOT ALL FIELDS. You’ll want to replace:

      test.mydomain.com/wp-content

      with

      mydomain.com/wp-content

      This will rewrite any internal hyperlinks and links to images in the posts and pages.

      If this is a premium theme or you have widgets with links or images, you may need to manually adjust those to use the new domain name.

      Let me know if that works for you.

  56. Thank you, this was very helpful. However, now when I visit the web page, I do not see the WP admin tool bar at the top when on a web page. I have to manually type in the sub directory to edit that page. Is there a way around that?

    • Hi Dajad,

      This is a caching issue. If you are using a caching plugin, be sure to delete the cache entirely. Also, delete your browser cache. The tool bar will reappear.

  57. I followed all your instructions.
    The problem is “wp-admin”.
    My old domain was http://example.com/demo then change it to http://example.com and it’s working. Everything in the frontend is working except wp-login.php and all the wp-admin links.

    i can only access the admin by using http://example.com/demo/wp-admin and if i try http://example.com/wp-admin.. it redirects to http://example.com/demo/wp-admin.

    HELP, please because it’s stressing me so much. I can’t find answers on the web –

    • Hi Jennifer,

      This is not a problem. This is the way it is supposed to work. Of course, the login will redirect to the demo folder because the WordPress application is in the demo folder. Remember, this process only moved the index.php file and left the WordPress installation in the demo folder. So, the wp-admin folder is inside the demo folder as it should be. The login will always display with demo in the url. Nothing is wrong with that and it will stay that way.

      Angela

  58. Hi there! I have successfully installed my WordPress site in a subdirectory and made the changes so that users can enter the root url and see my site. I love this setup, however I no longer see an admin panel at the top of each page when I am scrolling through the site, which is a pain b/c I love using the “edit this post” feature and others when I find things that need updates. Have you seen this issue before and do you have any tips for fixing it?

    • Hi Ashley,

      That is very strange. You might try deleting your browser cache or see if you have caching enabled via a caching plugin and delete the cache and see if that fixes the problem.

      Angela

  59. Angela,
    Thanks for the post it helped me migrate everything correctly, and now my pages open up just fine under… mysite.com, and not mysite.com/wp.

    I have an issue though…. how do i create a page in wordpress that has the same name as a subdirectory in my ftp? I was hoping this wasnt an issue but might have to re-do a lot of work if i am not able.

    Fred

    • Hi Fred,

      Yes, this is an issue, because WordPress won’t be able to resolve the URL properly. You can certainly have a page the same name but use a different slug. For example, if the page needs to be called “blog,” you can have the slug (url) be something like the-blog, our-blog, my-blog, blog-page.

      Does that make sense?

      If you decide to rename the subdirectory, there are a few things you’ll need to do which are similar to what you would have to do if you had physically moved the entire WP install to the root. Here’s what you would need to do:

      1 – Change the WordPress Address URL (Settings > General) to use the new subdirectory name. Click Save Changes. You will be booted out of the WordPress Dashboard.

      2 – Using your File Manager or FTP application, change the name of the folder to use the new name.

      3 – Edit the index.php file in the root directory to use this new folder name.

      4 – Now, you should be able to login to the site via http://mysite.com/newsubdirectoryname/wp-admin

      5 – You will need to use the Search & Replace plugin to search the CONTENTS of the pages/posts (not the full search and replace which can cause a lot of problems) to replace the old URL with the new URL — this is primarily to fix links to images within the posts and pages. You might have other internal hyperlinks you need to fix or plugins or widget areas that reference the old directory you’ll need to edit.

  60. Hi Angela,
    Great article… very helpful, I have runned into a problem here

    I noticed that in your instructions you have noted that :

    “c) making 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;”

    how can go around this… i need 2 folders to be a part of site structure, as they contain archive files such as PDFs and images and are a key part of our site which users will need to access.

    Therefore, using my permalinks, i had my site be:

    http://www.mysite.com/

    and have created pages and post to access some PDFs stored in a folder called newsletters in our ftp server.

    ie.
    http://www.mysite.com/newsletters/newsletter_a.pdf

    this was not an issue before the switch… how do i fix this? i want the post/pages to keep the same structure as the folders on my ftp site.

    Thanks in advance for the help

    • If you have a page called newsletters, you cannot have a folder called newsletters. A simple fix would be to change the slug for the newsletters page to be our-newsletters or all-newsletters or simply news.

  61. Worked like a charm! I have my blog at Banahosting and I had to upload the htaccess to the root directory. Hope that helps to somebody else! Thanks for this post!

  62. Hi Angela,

    My wordpress site is hosted using an Apache instance of EC2. Ive followed your instructions but now I cannot log into the admin site, nor is any CSS applied.

    Please help!

    my site is: syaggarw.com (you can see what I mean)

    Thanks in advance!

    • Sorry for the late response. Please contact me via my contact form if you are still stuck. It’s hard to troubleshoot via the URL alone. I would definitely check the FAQ page for this process on my site to make sure you edited everything correctly. It could be a simple typo.

  63. Great information. Maybe I’m over complicating this, but specifically I want to create the new WordPress site in a folder in the main host directory where all my other sites are located.

    Example:
    http://www.mainhostdirectory.com < All my sites are here in sub folders for each site.
    http://www.mainhostdirectory.com/NewWPsite http://www.mainhostdirectory.com

    And I’ll also be pointing the clients url from an existing site on another server and that URL is http://www.NewWPsite.com.

    I have Googled this specifically and can not find anything that explains just this type of change up using WP.

    Thank you

    • With hosting other domains on the same hosting account, the main public_html folder usually has the main web domain associated with the hosting account pointed to it, so whatever is in the public_html folder is usually the contents of that main domain’s site.

      For my hosting account with Host Gator, for example, my main domain is angelabowmandesigns.com. I have the following in my public_html folder:

      index.php – this is the index file related to the angelabowmandesigsn.com WP installation below

      angelabowmandesigns – this is a folder I have my angelabowmandesigns.com WP site installed in but the domain really is pointed to the root public_html folder since this is the main domain for my hosting account.

      askwpgirl.com – this is a folder with my askwpgirl.com WP installation, and that domain points to this folder as an “add on” domain

      moongoosedesigns.com – this is a folder with my moongoosedesigns.com WP installation, and that domain points to this folder as an “add on” domain

      So, I think what you are trying to figure out is the between an “add on” domain whose site files reside in a subdirectory of your public_html folder and simply installations of WordPress that are installed in subfolders of some other site, such as askwpgirl.com/someothersite (with someothersite being a subfolder also in the public_html folder)

      If you have developed a temporary site inside a subdirectory on your hosting account and then you need to “move” that site to it’s final location, then you might want to use a plugin like BackupBuddy that will assit with the migration and rewrite all of the URLs for you from the temp URLs to the actual URLs. I have an affiliate account with the makers of Backup Buddy plugin: http://askwpgirl.com/go/backupbuddy.php

      Let me know if you have other questions. I know it’s confusing when you’re first untangling all this and figuring out what the differences are between parked, add-on, subdomains and subfolders. It does take some experience to differentiate between all of these. Then, when you get into creating “development environments” and needing to “migrate” the site, and that’s a bear. I’d love to write a post on site migration from one URL to another. WordPress.org has a good post:

      http://codex.wordpress.org/Moving_WordPress

  64. Thanks so much for these clear directions. It really helps to follow them, rather than just breeze through as I just did and screw up the siteurl settings. I was able to work through my issues by editing my functions.php file in the child theme via ftp, adding the following (and inserting the proper addresses for “example.com”:

    update_option(‘siteurl’,’http://example.com’);
    update_option(‘home’,’http://example.com’);

    Once I could get in again, I corrected the addresses in the settings panel, then deleted the update_option lines from the functions file (which override the dashboard settings otherwise).

  65. Hi Angela

    I’ve been struggling with this for a couple of days now and have tried all the different solutions to no avail.

    My wordpress is hosted in its own directory on an EC2 instance with an elastic IP. Everything was working fine till I was accessing the WP admin through the elastic IP.

    I have a domain name that I have re-directed to the WP directory like so -> http://elasticIP/wpdir. Now, the website works fine for the most part through domainname.com but I’m unable to access WP admin through it.

    I have already created a copy of index.php in the /var/www/html folder pointing to the wp-blog-header.php file. I also have a .htaccess file with this content inside (I don’t use pretty permalinks now)

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www.)?domainname.com$
    RewriteRule ^(/)?$ wpdir [L]

    What do I need to change to make WP admin work via the domain name? My WP and Site URL currently points to the elastic IP and not the domain name. Appreciate any help.

    • Angela-
      I have successfully redirected my photography wordpress test site from the subdirectory to the main url but now the NextGen Pro plugin is not recognizing the correct path to the images… all the galleries have broken file paths.

      WHen I go into each individual gallery, the images are all there but the path is showing the original url instead of the subdirectory url they are actually in. The field is not editable either, so I can’t update it… also cannot find any documentation on Next Gen site!

      Do you have any experience in changing the path to the images in each individual gallery?

      This is the PRO version, but I uninstalled the PRO plugin from the test site, re-downloaded another plugin from my member area, then re-installed the PRO plugin on the real site url. The galleries are still not recognizing the correct paths to the images.

      I’ve put in a support ticket to NextGen, but thought you might have done this before.

    • Perhaps the WordPress files are not installed in the correct location. If you need more help, please email me via my About page.

  66. Hi Angela,

    First of all, thank you for this awesome post (I’ve bookmarked it for future reference).

    The problem I’m having is that I have 3 WP installations in different subdirectories, within the same hosting account. If I copy the index.html file from subdirectory #2 to the root, it would replace the one from the first site (which was already “moved” and is working fine). How can I make this work for the second, third, etc. sites without breaking the first site?

    Please help!

    Thank you

    • Yes, that is a problem when you have three WP installs on the same hosting account, so how you manage this depends on what each of the installations is for. You certainly don’t want ALL of the installations to represent the content for the one site that is the main domain for the account. In my case, I have the index.php file for the main site in the root directory, and all of my other domains are in their own directories and don’t require or need for me to move their index.php file to the root for any reason. What is in your three installations? Why do you have them? Are they for different websites? If they are for different domain names, then, of course, you don’t need to move their index.php file to the root for any reason, because the root only relates to one domain and not to the others.

      • Thank you for responding. I have 3 different websites, each with their own domain and each installed in different subdirectories, for development purposes. I followed the steps for the first site and everything worked fine. What I’d like to do is have the the other 2 sites show “domain1.com” instead of “domain1.com/folder”?

        Really appreciate your help

        • Sorry, I meant:

          Site 1 – “domain1.com” instead of “domain1.com/folder”, and
          Site 2 – “domain2.com” instead of “domain2.com/folder”

          • If the other domains are all installed in their own folder, and inside that is yet another folder, you can follow my instructions and move the index.php file up one level only to have the site urls display from the folder for that domain instead of from the subfolder. Does that make sense? You can contact me directly via my about page if you need more help to troubleshoot.

  67. Many thanks for your instruction on how to make Wp on the root of a site, clear and simple and worked perfectly. Cheers!

  68. Hi Angela,

    I just wanted to leave a note thanking you for all the information you provide! It helped me resolve my “WP-move-gone-bad-day”.

    I could finally leave my website in the subdirectory without it showing. Thanks !!

  69. Hi Angela. I think I stuffed up my brand new WP install because things went wrong when I modified the WP and site directory entries in Settings. Now I can’t log into my wp-admin any more (I get the login page ok, albeit the theme i messed up), but clicking on LOGON button results in error ‘/wp-login.php not found’. How do I reset the wp and site URLs? Are they in an ini file somewhere, or do I go to the db? I’m very new to WP. Any help greatly appreciated :)

    • Hi all. Found out how. I went to my CPanel. Launched phpMyAdmin. Selected my database. Listed all records in wp_options. Edited the 1st record (field=siteurl). Saved the record. WP works as before now. So all good. Cheers, Mark.

      • It’s so nice to know how to login to phpMyAdmin because you can fix things quickly there if anything gets messed up. Good job!

  70. Hello Angela,

    I am trying to do this very thing and I am having problems. It appears the urls I am using for either the index.php or the wp-config.php are off-my guess anyway. I am trying to make:

    http://burrellcenter.com.ixia.arvixe.com/bbh/

    Show up at:

    http://burrellcenter.com.ixia.arvixe.com/

    When I follow the instructions to a T-I get these errors:

    Warning: require(./bbh/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in E:\HostingSpaces\bbhadmin\burrellcenter.com\wwwroot\index.php on line 17

    Warning: require(./bbh/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in E:\HostingSpaces\bbhadmin\burrellcenter.com\wwwroot\index.php on line 17

    Fatal error: require() [function.require]: Failed opening required ‘./bbh/wp-blog-header.php’ (include_path=’.;c:\php\includes;C:PHP5\PEAR\Config.php’) in E:\HostingSpaces\bbhadmin\burrellcenter.com\wwwroot\index.php on line 17

    Any ideas?

    Thank you!

    Mike

  71. Many thanks for this post, really useful!

    I’ve only had one hitch and it’s probably something simple, the home page in my nav is still referring to the /wp/ directory and showing a blank page.

    Any solutions greatly appreciated!

    Thanks again

    G

  72. Angela:

    Though I am not new at Website admin and design, I am brand new to WordPress. I cannot tell you how EASY you made making my site live (I had installed wp in a /wp directory – old habits die hard).

    Your simple, straightforward directions allowed me to have my site live in less than 10 minutes.

    Fortunately I had moved to a Web Hosting provider and they are very WP friendly. I also had no previous website junk left in the root directory to deal with.

    Thanks again and keep on writing tips.

    bro jeff

  73. Hi Angela, It really worked for my website (Under Construction, just started to build Actually, I owe 3 linkedin groups which are considered most active and have reach strength of membership)…..I just followed your first 5 steps. Thank you so much. I really like the idea of keep sub-folder as it is.

    Regards
    Rajeev Jain
    LI-Profile: http://in.linkedin.com/in/rajeevjain1/

  74. OK. As far as I can tell I followed the instructions exactly as above but unfortunately there is some issue that has messed up my website. I have installed the wordpress site on a subfolder called wpssf. I changed the line in the index.php file, and updated the wordpress URL.
    The old site is still up there (the original reason for doing this is to migrate from a static html site to the wordpres one), but all I am getting when I try to access the new one is http://stopsharkfinning.net/wp-login.php?redirect_to=http%3A%2F%2Fstopsharkfinning.net%2Fwpssf%2Fwp-admin%2F&reauth=1

    I’m guessing it may be some redirect problem? Can anyone help please? This is something I have spent a lot of time on and aproject I really care about!

    • Hi Eric,

      This can happen from a bad theme or plugin. Try logging in via FTP and rename the plugins folder to plugins-old, and delete all but the TwentyTwelve theme and see if you can get the site to come up. If so, then the problem is with the theme or one of your plugins. Try activating them one at a time to find the culprit.

  75. Hi Angela,

    Thanks for the great tutorial, and I’m almost there, but I put my test site in a sub-domain and not a sub-directory e.g. test.mysite.com and not mysite.com/test

    I’ve tried all sorts of variables for the new wp-blog-header.php location in the index.php file, but nothing is working (I keep getting the ‘Warning: require(./wp-blog-header.php) [function.require]: failed to open stream:’ error message.

    I’m guessing this is due to it being in a sub-domain and not a sub-directory. Any help gratefully received.

    Thanks,

    Pete :)

  76. Hi Angela,
    This page is bookmarked, have used your method on several sites and works great!

    I encountered a problem today though…
    I am using a site with multiple users, and after using your method/move, when a User logs out, it redirects them back to the subdirectory ie http://www.website.com/wp/ (where the front-end site used to reside and where the wordpress is still currently) and it comes up as 404 missing page?

    I copied index.php as opposed to moving it to root directory, so there is still an index.php in the subdirectory and I thought this should then still work but guess not.

    I have tried adding Redirects from http://www.website.com/wp/ to http://www.website.com but these are not working.

    Have you encountered anything like this before? Possible solution?

    Thanks
    Jamie

    • Definitely NEVER use redirects to fix this. That will cause more problems. After following these directions, the URLs will display for the root of the site, as will the home page. The login page will still be under the /wp directory as thewebsitename.com/wp/wp-admin

      However, on logging out, the loggedout page will still be wp/wp-admin since WordPress is still in the subdirectory. The only thing my instructions do is allow you to VIEW the URLs for pages and posts from the root. You have not actually moved the WP installation. I have never seen a redirect from the logout to some static page, so I don’t know what would be causing that unless there was a typo when you followed the instructions in this post.

  77. Wow, I am sooooo pleased with this method! I had no trouble at all getting this to work and I was expecting the worse to happen (I did multiple backups b/c I was scared of losing all my many hours of work) but your instructions were a total breeze compared to other methods I have researched.

    I have one question though… I have the Google XML Sitemaps plugin installed and now that I have followed your instructions I noticed there are now two sitemap.xml files residing in the files. One is in the root directory, and the other is in the original subdirectory I initially built the site on.

    Should I remove one of those? Does this cause any issues with Google indexing my site or thinking there is duplicate content?

    Thanks again for these instructions, you saved me tons of time and I will be doing all my new sites like this from now on!

    • Hi Jen,

      Delete the XML sitemap in the subdirectory and then use the plugin to regenerate the one in the root, so the pages have the correct URLs.

      If you had the site up for awhile previously with Google, you might want to sign up for a Google Webmaster Tools account.

      Also, install the Redirection plugin and do manual redirects on any of the old URLs that might have been index by Google. Google will eventually recrawl and reindex the site, so those old URLs with the subdirectory in them won’t be an issue over time.

      Angela

      • Thanks Angela-
        I already had this site initially set up in my Google Webmasters account, but it had not been verified yet. Just followed your instructions with removing the sitemap file in the subdirectory and then regenerated the one in the root (although I think it had already done so on its own after me making more changes to the site today).

        On a side note… do you enter both the www and non-www versions of your sites in G. Webmasters? I had read that we should have both of them, then verify both sites, then set the preferred domain to one or the other.

        Is that the way you do it? I’ve always been kind of confused by the www vs. non-www versions. I’m hoping I have my settings correct so it doesn’t look to Google like two sites with duplicate content.

        Thanks for your help, you have been wonderful!

  78. Hi Angela,

    Just did this properly on a new site with a subFOLDER! BRILLIANT!!!! You are a miracle worker – thanks so much – from now on I’ll be using this on every WP site I build.

    Charles

  79. Awesome Information on this page. I tried a number of combinations to try to get this to work properly. I have done this before in wordpress and it was a piece of cake, but it must have been the hosting company I was using (HostGator). Today my client is using Godaddy as the host.

    I followed all of these steps to a T, but was unable to get it to work. What I ended up having to do is copy .htaccess and index.php file from the subdirectory to the root. I deleted the original .htaccess and followed your steps on having WP create a new file. When I tried http://www.domain.com without the subdirectory, I was getting “Warning: require(./wordpress/wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home/content/31/8187731/html/wp/index.php on line 17″

    This told me something was up with how this file was being referenced. So I changed the code in the root level index.php file
    From:
    require(‘./wp-blog-header.php’);
    To:
    require(‘WordPress/wp-blog-header.php’);

    I also had to make some changes to the .htaccess file.

    The home page loaded fine but none of the other blog pages would load. I then went into the /Wordpress/index.php file and removed the step were I added and replaced it with the original code.

    I have spent way to much time to try to figure out if there is a better way of doing this. Your feedback would be great Angela and I wish I found this article last night. Thanks again for this post.

      • The point that I am trying to make is that

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

        Does NOT work.

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

        Works

        The issue here I think is the relative URI . I did not try to this but I would bet /Wordpress/wp-blog-header.php.

  80. Hi Angela, Thank you so much for this post!! I have bookmarked this page and others, because they have been so helpful. When my site is up, I will definitely provide you with some link juice. :) Just one question, but will the steps above work if I am using a Genesis and StudioPress theme? I have just completed a WordPress sub-directory install (for all the reasons mentioned above) only to be told it might not be possible to copy or move my website over to the root? Would you be able to shed any light on this? or Should I just start fresh and do a root directory install.

    • The reason perhaps they told you it would not be possible to copy or move the website to the root is because it is cumbersome to actually “move” the installation to the root and will break a lot of stuff — like all your image links. This is why the process outlined in this post is awesome, because you don’t “move” WordPress — you just tell WordPress what URL you want to display the permlinks from and what URL the WordPress application is actually installed under. Simple. Clean. Easy.

  81. Hello Angela,

    Since a while I redirected all the ancient static pages on my painter’s website to my WordPress installation which I formerly used as a blog. And now I wish to cancel the /blog/ from my Url to keep only the root (hazlotopics.com). But I could never achieve (hopefully I’ve been able to switch back to the previous state and my site works again). So I’d like to precise a couple of things with you if you are ok.

    1/ In the WP codex I found this sentence: “The “Home” setting is the address you want people to type in their browser to reach your WordPress blog”. But in another page of the WP codex (Using a pre-existing subdirectory install) : “In the box for Site address (URL): change the address to the root directory’s URL”.
    So it looks like I did it wrong when changing the first field (Home) to the root directory. I should have change the second one named Site Url. Do you confirm?

    2/ After I did it, I could not login anymore, my site turned upside down, and the WP Settings page changed into a warning page wherein it was written:

    Warning: is_writable() [function.is-writable]: open_basedir restriction in effect. File(/) is not within the allowed path(s): (/home/XXX:/usr/lib/php:/usr/php4/lib/php:/usr/local/lib/php:/usr/local/php4/lib/php:/tmp) in /home/XXX/public_html/blog/wp-admin/includes/misc.php on line 133

    Warning: Cannot modify header information – headers already sent by (output started at /home/XXX/public_html/blog/wp-admin/includes/misc.php:133) in /home/XXX/public_html/blog/wp-includes/pluggable.php on line 876

    The first warning mentions php4 but when I checked my htaccess I could never find something like the sentence “AddHandler application/x-httpd-php5s .php” (found in your other post) even though my web hosting runs with php5.

    3/ And finally, in case I can fix it and change my Url to the root, I’m not really sure of how to set the plugin “Redirection” in order to redirect all my actual /blog/ Urls all at once (and same for my old static pages which have all been redirected one after the other with the redirection tool of the cPanel).

    Hope my questions are not too confuse.. Hope my english is Ok too!

    Thanks in advance.
    From France, kind regards.

    Hazló

    • Hi Hazio,

      1 – The process I describe in my post are instructions for successfully keeping the WordPress installation in the subdirectory while display all post and page URLs from the root.

      2 – It’s important to not have any typos or forward slashes in the URLs. Not sure if your problem is related to that or the .htaccess file. You can contact your web host to ask them how they are handling the PHP 5 selection. Some do it via .htaccess, others do not. If you did not edit the index.php file and move it to the root, then there can be problems with WordPress finding the installation. Or, your theme could be poorly coded and not finding things correctly. If something was not set correctly, you can login to your web hosting control panel and access the WordPress database via phpMyAdmin and reset the settings. Please see this post on how to do that:

      http://askwpgirl.com/moving-wordpress-from-subdirectory-to-root-faq/

      3 – It’s hard to do bulk redirection simply because ALL of the image URLs, uploaded files, and WordPress application itself will still be located in the subdirectory. In this case, it might be better to actually physically MOVE the WordPress installation and then you can use an .htaccess redirect to do a bulk redirect to the root, but you’d also need to run the Search and Replace plugin on the content of the site to replace any image urls, uploaded file urls, and internal links to the new url without the blog in the url.

      For the old site HTML files, the bulk .htaccess redirect (see below) will simply redirect the exact same name URLs not the old htmls, so you will need to re-enter the new location for those in the Redirection plugin (though since those redirects are already in place, the .htaccess file may take care of the redirecting them yet again).

      Here’s the .htaccess bulk URL redirect command:

      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} ^mydoman.com/blog$ [OR]
      RewriteCond %{HTTP_HOST} ^www.mydomain.com/blog$
      RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301]

      Again, this ONLY works IF WordPress is MOVED to the main directory and is NOT in the subdirectory. But, first, take care of what was messed up on the current site, so you know everything works before you attempt to move anything in the FTP folders. Let me know if you need some help.

      • Thanks a lot Angela for taking time to answer to the questions of a “rookie”. I’ll check the php situation with my web host.
        Concerning the htaccess, I thought I could maybe first replace the main directory current one (which I saved) with the one of the wordpress subdirectory and then copy inside it the current redirections (old static files).
        And of course I’ll try to use your bulk url redirect command for the current /blog/ Urls.
        Does this make sense for you?
        It seems to me easier than to physically move the WP installation because I’m a bit scared with the searchandreplace scripts or plugins (I’m not that aware of how to set them good and they can easily break all).
        Thanks again for your patience!

        • Everything is fine now after I carefully followed your instructions.
          Concerning my ancient static files,I finally found a way to redirect all the folder to the actual site, with the following code in the main htaccess (excluding some pages that I prefered to redirect to a specific url) :

          RedirectMatch permanent ^/AncientFolder/(?!SpecificPage.html)(.*)$ http://www.domain.com/index.php

          So Google should be happy!

          Thanks again Angela for your helpful reply, for the posts here, and for the time you spend for the others.
          All the Best!

  82. Hi

    I am just about to start implementing the switch over and have just one question. My current site which is in the root directory has an index.html file and then numerous html files for the various pages.

    I am wanting to do 301 redirects for all html pages to my new wp pages to keep my link juice.If I have to remove the index.html from the root then won’t the 301 for this page be useless?

    Any help would be great and I really appreciate your excellent advice.

    Regards

    Robert

    • Hi Robert,

      When you are ready to make the switch, copy all of your old HTML files into a folder, so they are no longer in the root. Later, you can download these as an archive and then delete them on the server. The reason I say to put them in a folder is just in case you need them immediately, but you definitely want to not have any of them in the root, particularly the index.html file.

      You do NOT need any of these pages existing to do the 301 redirects, and it’s better if they are deleted ultimately.

      After yo do the process outlined in this post to move your WordPress index.php to the root and make the other changes per the steps in this post, then you can install the Redirection plugin and do 301 redirects on all those old HTML pages to your new WordPress pages. Again, those old html pages can be deleted and do not need to exist in order to redirect their URLs to the new URLs. However, you will want to make note of all those old URLs in order to do the redirects correctly.

      Good luck! Let me know how it goes.

      Angela

  83. Just thought I’d toss in something that was helpful for me. While following these directions worked for my homepage, all subpages would return a HTTP Error 500 (Internal Server Error). No matter how much futzing with the .htaccess file and/or the index.php file I did, nothing seemed to work. On a whim, I deactivated *all* plugins and: voila! All subpages began working. I then turned each plugin back on, and all of them seem to work fine now. The one problem I’m still having is that I can no longer seem to preview changes to pages, instead it returns, “You do not have permission to preview drafts.” This is a bummer, but at least everything else is up and running.

    • Hi Travis,

      Thanks for writing. Yes, that is very puzzling. Sounds like a badly coded plugin. I have never had an issue with plugins with this process. However, one thing you can do is DELETE your cookies in your browser and delete your browser cache. That should solve your preview issues. It could be the authentication for your user session vis a vis the browser cookie got confused.

      Let me know!

      Angela

  84. Hi Everybody,

    I have successfully migrated from olddomain.com/wordpress to newdomain.com. It is actually stored under newdomain.com/wordpress but I have made this “transparent”,

    All works fine till now… crossing fingers ;-))

    My only concern are google webmaster tools… only available for root domains. So I cannot transfer my olddomain.com/wordpress links to newdomain.com.

    Anyone has got the same problem and has managed to fix it?

    Thank you in advance for your help!

    • If you are changing domain names, there are two things you can do:

      1 – Add both the old and new domains to Google Webmaster Tools. You will have to download and FTP the unique html verification file to both the accounts. Then, you can indicate in the Webmaster Tools for the old account that you have changed the address. This is just a nice informational thing to do for Google.

      2 – If you had a lot of traffic on the old domain, then you can install an .htaccess file on the old domain with this code to do a wild-card redirect to the new domain. It will automatically redirect all all the old URLs to the new URLs:

      RewriteEngine On
      RewriteBase /
      RewriteCond %{HTTP_HOST} ^olddomain.com/wordpress$ [OR]
      RewriteCond %{HTTP_HOST} ^www.olddomain.com/wordpress$
      RewriteRule ^(.*)$ http:/newdomain.com/$1 [R=301]

      Do not use this rewrite to redirect mydomain.com/wordpress to mydomain.com as that will mess up your access to the WP admin directory if you still have WP installed in the subdirectory.

      If you did have a site at mydomain.com/wordpress which had a lot of traffic for which you just decided to display at mydomain.com, then you can use the Redirection plugin to redirect the old URLs to the new ones that do not contain the /wordpress.

  85. Hi Angela hoping you can help me. I have a site set up for my son who is in the NICU to keep my family up to date with his progress. I changed the WP URL which caused the site to break. I fixed it eventually by editing the config file but my theme looks like it’s not working anymore. The theme is showing installed still but the HTML/CSS is gone from the site. I am wondering if I need to edit another file to fix this…. can you assist? It is the contango theme and all the theme files are showing in my hosting folder including the css…. I saw something out there about editing the style.php to fix but cannot find that file…. Thanks for your help!

  86. I’m doing just this for a client and am overjoyed that someone was great enough to break it down. I’ve not done this yet and this looks like it will make the job a whole lot easier. Thanks so much, Angela!

  87. Thank you so much for these clear and concise instructions. I read the ones on the official WordPress site first, but found them a bit confusing as they seem to implicate a 14 step process may (or may not–HAH!) be necessary. Yours are much better and took literally 60 seconds to implement! They also saved me tons of time, as I was considering trying to migrate my site from an old Drupal install to a new WP one–eeeek. Knowing I could develop the new site fresh in a WP subdirectory and “move” it instantly to root made my life 10,000 times easier, since doing anything remotely complicated with Drupal is a triple nightmare.

    A note: I’m on Hostgator and didn’t need to copy/move .htaccess. I deleted the old .htaccess file in root that contained the Drupal settings, and it spontaneously regenerated.

    Thanks again!

  88. Interestingly, I was in a panic and didn’t have time to call the service provider and have them start changing the staging site’s DNS – so I took a crazy chance and just re-uploaded the entire staging site (wordpress installation and all) to the root directory (there was nothing there previously). Then I logged into the Dashboard and changed both addresses to the root level and it worked! Some of the images are still pointing to the old staging area uploads but that’s OK. This service provider doesn’t locate the database where the domain is so it still was able to connect to it without changing the config.php file. Just an FYI for anyone else who runs into this brick wall at 7pm when the site has to be live ASAP!!

    On to a new installation this time I’m going for a subFOLDER and I will be trying this method out. It’s a lifesaver! I wish I had seen your article in 2011. I searched the web for this topic a few years ago but couldn’t find a good solution – only some scary looking plugins that “might work”.

    Thanks for figuring this out and for your speedy response!

    Charles

    • Yes, the config file should not have to change if you stay on the same host. If people decide to actually physically move the WP installation to the root, instead of following the method outlined in this post, they would want to first change the General Settings to remove the / and the subdirectory name (important that site does not end with trailing /), then move all the files to the root (aka public_html folder), then use the Search and Replace plugin to rewrite the URLs to the images and hyperlinks (important to ONLY do Search and Replace on CONTENT area, otherwise, there can be unexpected consequences doing a full search and replace in the database — such as republishing of all your posts to the RSS feed).

      For “moving” WordPress or doing other types of migrations from one site to another, particularly if the site URL changes (from a dev server to a live server), I usually use the BackupBuddy plugin, because it automatically handles all the URL rewrites correctly, with the exception of some plugins I’ve used for sliders that might have the image URL stored in a way that BackupBuddy does not typically access.

      Anyway, glad this whole process worked out for you.

  89. Hi

    I was VERY excited to find this post and followed your instructions to the letter but can’t get the menu items working. The site redirects properly but when I remove the “staging” part of the URL from the menu items the menu goes to the root directory – where there is nothing there. You mention a possible fix in the header.php file but you don’t say what that is. Is it in here?

    Thanks
    Charles

    • Hmmm… the wp_get_nav_menu should just get the URLs for the pages, which, if you followed the instructions, should now use the root URL not the subdirectory. Have you created a custom menu under Appearance > Menus or are you using the default menu of pages?

      Can you visit a page okay without the subdirectory in the URL (not using the navigation)?

      You can contact me via my contact form with your URL if you want me to take a peak.

      • Thanks for your SPEEDY reply Angela, this is awesome! I need to make this live ASAP! Yes, I’ve used Appearance > Menus – 2 of them are custom and the others are just a Page but I could make them custom. I can’t remember if I removed the index.php file from staging when I tried this earlier today though. I don’t mind giving you access, but how do I do it without posting login info here?

        Charles

      • Hmm what seems odd is the permalink thing – you have your path blacked out so it’s difficult to tell how it works – but the original permalink where my wp is installed was:

        staging.cowandcompany.ca

        – now if I make your change for example “contact” would look for this –

        cowanandcompany.ca/staging/contact/

        which isn’t correct so I can see why it comes up blank – even if I use dot…

        cowanandcompany.ca.staging/contact/

        it’s in the wrong order.

  90. Hi Angela,
    Thanks for your instructions. I have followed them, as well as the official codex instructions, and keep ending up with a blank root homepage. Any ideas?

    • Ah! I wonder what might be happening. Can you contact me via my contact form with the URL to your site? It does sound like perhaps a little mistake.

      • Hi Angela,
        I wanted to follow up on the record and say that migrating my site from a Windows account to a Unix account resolved all the of issues I had been experiencing. Your instructions took me all of 90 seconds just now to get a working site. Thanks for pointing me in the right direction!

  91. This was a GREAT help — however, I have one big problem that could be entirely my own doing.

    I’ve changed everything as suggested, and my blog that was previously under http://website.com/renewal is now appearing pristine on http://website.com — great!

    However, I have a completely unrelated subdirectory under my root called ‘slide’, and while the index page of http://website.com/slide will display fine, anything UNDER the slide directory (like http://website.com/slide/reader/read/chapter_1/en/0/1/page/1) WordPress interprets as some complicated page name and tries to display using WordPress–which of course isn’t going to work!

    If I change the permalink structure to the default (ugly /?page_id=##), the problem is solved, but then I’m left with ugly permalinks and faulty links all over the place since I’ve been using structure using the post/page title everywhere up til now.

    Any suggestions at all? I’m desperate!

    • Hi Courtney,

      I have had other HTML files in subdirectories and have never had this problem except when there is a similarly named page in the WordPress installation causing WordPress to try to interpret that URL as a post or page. WordPress will try to parse any URL that it sees to see if it is a WordPress page or post or category or archive, etc. I think it’s important that your naming conventions are strictly followed or WP will choke. For example, if you use capital letters in your directory names on the server, then the browser may not interpret the URL correct and WP will try to find the page and not be able to find it. If you want, you can email me via my contact form, and I’d be happy to poke around your FTP structure to see if there is something obvious that could cause the URL to not be read. It’s often something simple.

      • It turned out the htaccess file in the subdirectory itself required a bit more finessing (ultimately, after a harrowing few hours, I finally realized the one line missing and resolved the issue).

        I’m now having issues with the permalink structure mucking up my bbpress installation, which suggests that I and my good friend .htaccess will be spending a bit more time together, but at least this has been resolved.

        • Here’s what I think is happening: You have too many .htaccess files. I would personally delete ALL of them (or rename them .htaccess-bk). Then, login to WP, and go to Settings > Permalinks and click Save Changes. This will automatically generate a correct WP .htaccess file for WP which then should not mess up your subdirectory with the static HTML files. I have encountered similar issues when people have had a bunch of .htaccess files all over the place. Having just the one with the proper WP settings as auto generated with the settings page will typically take care of these problems.

          • Alas–an excellent suggestion, but ultimately a futile one. WP generated a lovely new htaccess file just fine, but bbpress remains intractable. For a plugin developed by the wordpress creators themselves, it sure does have a lot of difficulty properly integrating with wordpress :/ It appears I’m going to have to try a commercial solution, as the bbpress support forums have never been much help…

          • Some more complicated functionality might not respond well to operating in a subdirectory. I know BuddyPress has a hard time if doing this method of installing in subdirectory and running from the root. What you might want to consider doing is using a plugin like BackupBuddy to backup the entire site (db and files) and “migrate” it to the root. Using Backupbuddy will help with all the URLs that need to be rewritten in the database when “moving” WordPress without breaking anything. You can also just physically “move” WordPress to the root and change the General Settings accordingly, but then, you would have to do some SQL query to rewrite the URLs from the old to the new. There are numerous blog posts on how to do that without messing things up, but I find BackupBuddy to be the most fail safe method. It’s possible, then, that bbPress will be happier running from the root rather than redirected to the root.

            I have never run bbpress out of a subirectory situation like this. Also, be sure it’s bbpress and not the custom menu item that needs to be fixed. However, it wouldn’t surprise me if being in the subdirectory but redirected to the root for the URLs could have confused it.

          • “Also, be sure it’s bbpress and not the custom menu item that needs to be fixed.”

            I can be quite sure it’s not the menu item, as even links such as the latest post in the freshness column or links to individual replies in a topic thread itself throw the same error. It’s very much that URL itself that’s proving problematic.

            I had actually originally intended to do just that–move the wordpress installation to the root and run it from there–but after seeing how complicated it would be and all of the database adjustments I’d had to take, I was relieved to find this alternative which seemed so simple.

            Do you know of any good hand-holding tutorials for using backupbuddy off the top of your head, or shall I do some googling now? I haven’t come across that option thus far, and it seems like the path of least resistance.

  92. Angela, before I proceed with your tutorial, can I get a confirmation that this is something that will solve my situation?

    Lets say for example my site is BIKE.COM. This is the main wordpress site. Its 4 main folders: cig_bin, wp-contents, wp-admin, wp-includes are in the public_html folder.

    I created a sub-domain called Shop.Bike.com. This wordpress site is also in the public_html but its 4 main folders are inside a folder called SHOP. Is the SHOP folder what you call a sub-directory?

    So knowing my current set-up, should I still follow your instructions? Because I was immediately lost with step 1. LOL! It says to install wordpress, but don’t install it in the root public_html, install it in a sub-directory. Which had me confused immediately because I’m trying to move my sub-directory site into my main site, so why would I do that? I know there is probably some basic understanding that’s flying over my head right now.

  93. thank you! this is exactly what I was looking to do. One problem I am seeing, if my old site was bookmarked, and you navigate to mysite.com/wordpress, it shows the “This is somewhat embarrassing, isn’t it?” error message. i tried a redirect from my control panel, but that does not work either. i tried to redirect mysite.com/wordpress to mysite.com, but it still shows the “This is somewhat embarrassing, isn’t it?” error message. any suggestions? thanks again!

    • Hi Jimmy,

      I would recommend you install the Redirection plugin and enter 301 redirects from the old pages/posts to the new URLs.

      Angela

  94. Just a followup from my post last night. After some further research, it looks like I should be using Linux so I’ve changed this in GoDaddy. After the change, I’ll see if I can get everything working properly.

  95. Hi AskWPGirl, thank you so much for taking the time to write all this up so clearly for everyone. I created a wordpress site in a “wordpress” subdirectory (www.collegecalm.com/wordpress) and was trying to change the Home URL to the main root directory. After some trial and error, I now have the site showing up at http://www.collegecalm.com but none of the images are showing up on any of the sub-pages. I did check the permalinks and saw that they were updated in the dashboard. Also, I have found that I cannot access the site admin dashboard unless I delete the web.config file in the root directory (I guess I do not have an htaccess file but this web.config instead??). When I do delete it, I can access the admin dashboard but the site no longer displays at all at http://www.collegecalm.com. I’m hosted on GoDaddy. You mentioned an issue with them updating once an hour. Do you think this could be the issue or is there a bigger problem? thanks, Sara

  96. Thank you for this info. I am doing a whole revamp of my website, and have more than one install of WP and some subdomains and parked domains – the main part of my site is currently HTML. I plan add a new WP install for my main part (root), and am glad to see I can run it from a subdirectory while still appearing as root (while also running other installs of WP on the site.)

    Can I have no other pages in the root that can be accessed once I virtually “move” the WP into root – or does every file need to be switched to a WP post/page? Does *everything* need to be in a subdirectory – or just pages and images? (There are other files in there, such as php redirects.) I have a contact POST form – can that be put into a WP post? Do these need to be put in a subdirectory?) I was planning to use redirect code on the old HTML pages to go to their new WP pages? Is that what the Redirection plug in is for? With Redirection do I need to enter the old page URL and the new post URL for every page that I switched from HTML page to WP post – doing essentially the thing I thought I was going to do – only through a plugin? Also it says Redirection hasn’t been updated in a while and isn’t confirmed to work with latest WP, does it?

    Further on Redirection, on a current WP install. I want to change the permalinks (to take out date and just use post name.) I tried and WP did not redirect the posts. With Redirection, if I activate it before I change the permalink structure, will it automatically redirect them? Also I plan to change the subdirectory name that the WP install is in. I used Velvet Blues to update links for another WP install that I changed the name of, but it was much smaller and I wasn’t worried about redirects so much since navigation is much clearer. Do I need to use Redirection instead for this too, or will Velvet Blues work?

    Thank you for all your info and help!

    • You can have other WP installs in subdirectories as well as subdomains. I have that on my site. For example, askwpgirl.com is in a subdirectory with the index.php file for it in the root, then I have a site installed in another subdirectory, which I access via that subdirectory and another subdomain in the a folder in the root directory. It all works fine. The only issue you could run into is if the subdirectory name matched the slug name (page or post or category url) of the main site.

      You should delete the old HTML files and use the Redirection plugin to redirect to the new URLs. Also, install the XML Sitemap plugin, so that will give the Google Bots a new sitemap to crawl. You definitely want to use the Redirection plugin.

      For the contact POST form, don’t use that! It’s a pain in the ass, and the Visual Editor in WP will kill the code. Instead, use a good form plugin to create a new form using WordPress, such as Contact Form 7, Gravity Forms (http://askwpgirl.com/go/gravityforms.php), or Fast Secure Contact Form. All except Gravity Forms which is a premium plugin are available from WordPress.org and can be installed via the plugins interface in the WP dashboard.

      If you had previously used the date and then change to the Post Name format for the permalinks, you will need to use the Redirection plugin to make that happen. I’m not sure it will automatically pick up on that change, though.

      If you change the subdirectory name, you are in a world of hurt. Everything will break or can break. You can do it, but you’ll need to use the Search and Replace plugin to do a global search and replace, but ONLY on the content. Some other plugin things might get screwed up to. In that case, I usually use BackupBuddy plugin (http://askwpgirl.com/go/backupbuddy.php) which you can do a “migration” to the new subdirectory and it will automatically rewrite all the URLs for you. No, do NOT use Velvet blues or Redirection plugin for this. That will result in weird, unnecessary redirection loops.

      Sorry it took so long to respond. I was on vacation when you wrote. Feel free to email me if you have any more questions.

      Angela

  97. Thanks for the article. I have an issue with a site that has existed for a number of weeks. I have completed the instructions and all works fine the site when you navigate it is no longer showing the subdirectory.

    However there are probably quite a lot of links from other sites which include the subdirectory in the URLs. I’ve noticed that on any parent level pages if you include the subdirectory in the URL it successfully redirects to the URL without the subdirectory, but any child menu pages with which you use the old site directory (i.e ‘domain.co.uk/site/parentpage/childpage/’) do not get redirected to ‘domain.co.uk/parentpage/childpage’.

    So the first question, is there something I have done wrong or is this normal?

    I’ve tried a RedirectMatch 301 but the redirect does not seem to be working, when I manually input a URL with the old Subdirectory it does not redirect to a version without it. Is my htaccess file correct (see below).

    And surely if I use a redirect match like that it would it close access to the admin pages/login?

    My htaccess file looks like the below at the moment (my wordpress install is in ‘subdirectory’) and I can successfully bring up the site and navigate pages without any problems at the root url:

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    RedirectMatch 301 ^/subdirectory/$ http://domain.co.uk/

    # END WordPress

    Any help would be greatly appreciated.

    • I think I may have answered my problem here with a bit of experimentation.

      I had permalinks set to ‘post name’ when I was getting this issue. However I couldn’t understand why I was having the same issue on another site I administer.

      Comparing all the settings I realised I had permalinks set to Day & Name for this other site.

      I adjusted the permalinks to match on the site I was having problems with, and any external links to a page on the site with a URL incl;uding the old subdirectory will automatically be redirected to the correct permalink page/post URL without the subdirectory.

      So far everything seems to work as expected.

    • You have to be careful with wild card redirects like this because your wp-admin and the wp-content folder are still located in the subdirectory, so I wouldn’t use that type of redirect. Instead, you can install the Redirection plugin and manually enter redirects for the old page URLs to the new page URLs. My instructions work very well for development sites. It’s a bit trickier to do this process for older sites because of potential external links.

      The reasons the posts redirect fine is because WP can generally parse that URL and figure out how to match the post title in the new location. Pages don’t work like that because of the page hierarchy — child pages. Changing a parent page URL will always result in broken links. Therefore, using the Redirection plugin for these specific pages is best.

      • Hi Angela,

        Thanks for the article for moving the WP site to root.

        I’ve used it alot and like Jaime, i realised that it seems to work only on the root level and the rest of pages/posts are still pointing to the development folder.

        Is using the Redirection plugin the best way to “tidy up” the urls to point to the root level?

        Daniel

        • When using this method, ALL of the posts and pages will display from the root URL. The only things that continue to “point” to the subdirectory are the WordPress dashboard (because the files for the dashboard are in the subdirectory, of course, sense we didn’t move WP) and the uploaded files (images and PDFs).

  98. Thank you *so* much for these clear instructions. I followed them, and they seem to be working. Moved my site and all is well so far!

  99. Worked great for me — thanks! I did have to go through the extra steps, including editing the .htaccess file, and I needed to upload that to the root directory as well.

  100. You have no idea how much time this saved me. Thank you for backstopping those Codex guys — I knew there had to be an easier way! Do you have a similar article for how to move (easily) from MAMP to a live host? That’s always a killer for me, and I know it forces a lot of people to develop ‘commando’ rather than deal with it.

    One thing I didnt see mentioned in the thread was to double-check plug-ins that use internal absolute links, in my case, there’s a social media plug-in that hard links to the blog within the same subdirectory. Easy enough to fix.

    • Thanks for the feedback, Aaron. I really hate plugins and themes that don’t use the correct relative links. That’s just a sign of poor development.

  101. Thank you very much! It worked!! I’m having a problem now… I have another installation of WP in another directory and I cannot access the admin page. Any clue why could be that?

  102. Hi Angela,
    I have a new version of wordpress. Can you tell me how you replace this to make it works?
    <?php
    /**
    * Loads the WordPress environment and template.
    *
    * @package WordPress
    */

    if ( !isset($wp_did_header) ) {

    $wp_did_header = true;

    require_once( dirname(__FILE__) . '/wp-load.php' );

    wp();

    require_once( ABSPATH . WPINC . '/template-loader.php' );

    }

  103. I just read over this and still debating whether I can tackle it. I need to update my site completely and the new one is done, I just worry about re-directs from Google. What will happen when someone stumbles onto an old page and it’s not there?

  104. Hope you can help Angela. I did as instructed, and everything is working and displaying right, EXCEPT when the contact form is submitted, the Thank You message is being displayed on a blank page (instead of in a dialog box on the site). The form contents are being sent and received properly. Here is the web address of the page containing the Thank You message: http://amgcatering.com/amgcms/wp-admin/admin-ajax.php?action=sendmsg_submit

    The site is using the Blocked theme, which is no longer supported by the developer. It doesn’t have any form plugins installed, so not sure what to do next. Thanks!

  105. Thank you for the great article… I’ve encountered a 50/50 success result of your steps and hoping you can help lead me in the right direction…. After following your steps, all the urls/links for any subpage of my site work perfectly. However, the homepage still tries to point to the subdirectory, and I get a page not found error – just this one page.

    any thoughts?

    Thanks in advance.

    • Hi, I think the problem may be that your menu item under Appearance > Menus for the Home page is still the old URL with the subdirectory in it. Check that. If you just go to your site – the main URL – does the home page show okay?

      • If I go to the base domain, it automatically appends the sub directory path to the url, and displays a PNF. I don’t see anything in the menu section that specifies an old path.

        Thanks for your feedback :)

  106. Hi AskWpGirl!

    I have a tricky question. I followed your nice instructions and wordpress is now in a subfolder and .htaccess and index.php in root. Everything worked fine for a year. Then I wanted to use a plugin called Boxer Pro. Boxer pro generates a short code that will show the content of several nice boxes on a page. The problem is that the code is only working if I type the whole address to the subfolder. Asked the company that delivered the plugin and they asked me why a used a subfolder… Do you know any way of solving this problem? Should i change my .htaccess?

    • Don’t change your .htaccess! That is not the problem. I don’t know how Boxer Pro works, but essentially, WordPress is installed in the subdirectory as are all your uploaded files, including images. So, in some cases, as with linked uploads, the URL with the subdirectory is needed. What we’ve done in my post is had all the page, category, and post URLs for the site (the site’s permalinks) use the root directory, but we did not move the WordPress application nor move the wp-content folder.

      I don’t know what you are trying to do specifically with Boxer Pro for which you are referencing the subdirectory, so it’s hard for me to tell if this is a “problem” or just the way it should work given the location of the wp-content folder inside the subdirectory.

      • Hi Angela!

        Many thanks for your reply:) I think I’m loosing my hair on this one;)
        I forgot to mention you that since I moved the htacess and index.php files to the
        root I can’t preview my pages correctly. I have to put in the subfolder name to preview
        the page. Update page works fine though..

    • If you had the privacy settings turned off (ie allowed Google to search the site in the subdirectory), then there will be old URLs cached by Google. This will resolve itself in a few weeks, but here are some things you can do:

      1 – Install the Redirection plugin and set up redirects on those pages to the new pages

      2 – Install the Google XML Sitemaps plugin which will submit your sitemap to Google and help Google crawl your site easier.

  107. Thank you very much. I know, I’m the 371st person to say thanks, but one can never have too much praise right? I do have one question. Someone at my web hosting company said she has seen things go wrong with this redirect process when people customize their sites. Since so many people do this, I’m guessing she was incorrect. Anyone know if her statement is true? I’m planning on creating a child theme and I surely don’t want any problems.

    • I do this a lot with sites. It’s just a nice practice to keep the directory structure clean. I haven’t seen any problems, except if I had internal hyperlinks to the subdirectory that need to now not include the subdirectory. Otherwise, all the images and other uploaded files will not change, because they still exist in the subdirectory.

  108. Amazingly helpful- comprehensive and well-explained. Definitely going in my archive of important info to be used again…

  109. I was wondering if you could help me. I have uploaded my wordpress page to my server but all the content in my site are gone. I have some of the links on my screen but they stand in the left side on the screen on top of each other and they are not supposed to do that and i’m missing my background and all of my pictures and the rest of my links can somebody please help me

  110. Hi! You have NO idea how useful your post was to me!
    When I saw WordPress’s own description, I was ready to give up trying to make the /wp disappear! O_O It is THAT bad.
    However, I followed your pointers, and as a so far ~5 hour long user of WordPress or any sort of website creating anything, it was easy to follow and figure out!
    Unfortunately my site was the kind that needed to move the .htaccess file as well, and it took me a while to figure out why I wasn’t seeing it anywhere: it’s a hidden file! Have to make it visible first *lol*
    So anyways, thanks for the awesome description!

  111. Hi, wonder if you are able to help. I wish I had stumbled on your post before starting. I have my wordpress running on my public_html. Is there any way of moving them to a subdirectory now? Reason is i am running my website on wordpress and now want to add a blog page. But I’m not having any success. I have a blog post and have edited the static pages in my options setting to the blog page. Now when i go to http://www.sitename.com/blog i can see the page with all the css etc and menu but no posts? Any help much appreciated. Thank you. Naz

    • Hi Naz, It’s hard to determine what might be the problem here. When you have a HTML files in the same directory as WordPress, you have to be careful to not have the HTML files be the same name as any WordPress pages, posts or categories, because that can confuse the server as to which content to display. However, if you don’t have static HTML pages in your public_html folder, then there is no reason why you can have a “blog” page on your site and set your Reading Settings to use that page as your posts page. If this is not working for you, then there may be an issue with your Theme. To test this, try to enable the default TwentyEleven theme and see if it works with that.

  112. YOU JUST SAVED MY LIFE– Was about to follow some crazy manual procedure offered in another forum…. This was smooth & easy! Thank you so very much for the excellent tutorial!

  113. Hello,

    I am about to move my wordpress to the root directory, then I read your explanation and the comments below and found that is easier than WordPress.org process.
    Before doing this, I have one question. I have some .HTML web pages that has the same design as my wordpress theme. This is why these pages contain links to posts in wordpress (http://www…..com/wp/example-of-post/). Should these links stay the same in those .HTML pages after moving wordpress? Or should I change them to http://www….com/example-of-post/.
    Thanks a lot for your help!

    • Make sure none of your HTML pages in the root have the same name/url as any WP pages. Then, yes, on those static HTML pages, you’ll want to edit the URLs to your WP pages to NOT include the subdirectory in the URL.

  114. You’re a genius WPGirl! I was dubious about building in a subdirectory then changing to root when it was all done after reading the ‘official’ version of how to do this. Then I found your simple instructions, which gave me confidence as a WP newbie, to go ahead – and it worked a treat. Thank you so much.

  115.  This seems to be exactly what I was looking for, I just want to make sure that all pages will move too, like mysite.org/wpinstall/about-us/ will move to mysite.org/about-us/?

    I’m sure this is a rookie question, but what the heck.

    Thanks alot for the great info!

    • Yes, the page URLs will no longer have the wpinstall in the URL and will display the same way as if you had installed WP in the root to begin with. Good luck! Read the FAQ if you get stuck or contact me.

      •  Wow, after worrying about doing this for weeks, it was almost anti climatic it went so well.   You rock!

        Thanks again,
        Matt

  116. Okay – I tried this.  I edited the index.php, change the settings in the WP control panel, but got an error.  I did not move the .htaccess file to the root.  Could this be the problem?

    The site is currently at uupoconos.org/wp

    Thanks for any and all help!

  117. Thank you a lot! Very helpful. Far better than org procedure! I messed up my site with wordpress.org explanation. But with this, I manage to do it very easily and neatly and successfully! Cheers!

  118. WP Girl.  (Reminds me of Word Girl on PBS my dauthter’s heroine) 

    I’m not sure if you missed my question above.

    • Hi Carlos, Your comment last month never appeared in my queue. Strange. I think it must have been a Disqus glitch. Anyway, per your question, Photocrati is theme, and what it sounds like is that you now want to use WordPress for your entire site rather than for just the blog. It is a bit problematic having the word “blog” be the subdirectory name, but you just have to be sure NOT to name any categories or pages “blog.” There are many ways to slice this. One is that you can install the Photocrati theme on your current blog and set up all your pages in your current WordPress installation, then follow my instructions to have these show from the root. However, all of the URLs for your blog posts will be changed. The URLs will no longer contain “blog” in the URL. So depending on how many inbound links you have coming to your site vis a vis those URLs, you may not care about that. The other option would be to install a new installation of WordPress at the root and then use the Tools menu on the old site to Export the old posts and then import them into the new site in the root. Either way, the URLs will be changed, since they will show from the root and not from “blog.”

      In terms of the word “blog,” you will have a page on your site called “blog” but you’ll want to make sure the SLUG (aka permalink) is something other than “blog” – such as “photo-blog” or “my-blog.” So you will create a new page with this slug, and the page title can be Blog and the slug will be “my-blog” and you can set the Reading settings to show your latest posts on this page. Photocrati may handle things a bit differently, but typically people have a static home page with images and a separate “blog” page for the latest posts.

  119. This process has been problematic for me. I figured out that the Security Plugin I installed is the culprit. I believe that it overwrites files in an incompatible way. Anyone else have this problem, and/or have a workaround?

    • Hi Jamie, Which security plugin? I know the Silence is Golden Guard is problematic, so I won’t be recommending that any longer.

        • Silence is Golden Guard wreaks havoc with WP installs in subdirectory and totally breaks the site, so don’t use it. There are so many security plugins, that I’m not sure really help all that much. The ones I find useful:

          1 – WP Security Scanner — use once to check your file permissions then delete

          2 – Firewall 2 – run all the time

          3 – Limit Login Attempts

  120. Hello WPGirl, thanks for the great info.  You make it sound so easy.  I guess everything is once you know how to do it!

    I originally created a website via a bludomain site and added my blog to it at /blog.  Now I want to switch to Photocrati which is a site plus a blog.  Of course the blog is also at /blog so how should I adjust the above directions?

    TIA
    Carlos
    http://WeddingMedia.net

  121. Hi TB,

    Sorry for the delay in response. I responded to another very similar question recently, so I thought I’d already responded. Since all the URLs display from the root and the links to all your posts and pages are root level links, I don’t see any SEO disadvantage. The only items from an SEO perspective that are linked via the subdirectory are the images and uploaded files.

    There was an interesting article on canonical URLs and a WP install in a subdirectory: http://www.wealthydragon.com/2009/04/22/all-in-one-seo-pack-pagerank/

    To quote this article:

    “The reported problems seem to have been caused where the WordPress files and the public URL were in different directories.

    “In these cases the canonical URL feature in the All-in-One-SEO-Pack apparently gave priority to the URL including the sub-directory in the address – which confused the Google Bots and led to problems.”

    However, in the example I have and write instructions for, there are NEVER any URLs served up from the subdirectory, so I don’t see how the Googlebots would be confused as this person says. Also, this article is 3 years old. From my understanding, the install in the subdirectory with the URLs being served from the root following my instructions is purely for convenience, and I’ve never heard of SEO problems with it (other than the article cited above, which doesn’t make much sense to me). Many people want to keep their directory structure clean, and this achieves that.

  122. Hi, I thought I sent you a question, but perhaps it didn’t go through.  I’m about to install wordpress in a sub-directory and want to know for SEO purposes if it matters if wordpress is installed in the root or a sub-directory.  Obviously we want as best a chance to rank high in Google and will use Yoast SEO, so does the directory matter?  Thank you!

  123. Thank you WordPress Girl! Your instructions are clear, precise and accurate-
    much needed in a geeky world where the English language is not often used well.

    John Parulis

    • LOL. You can thank the great training I had at Quark as a technical writer. Though, many are too young to even know what Quark was/is. Back in the mid-90s, it was an awesome place to work, and I got lots of practice writing the post-release tech notes.

  124. Hi, just curious if the big three search engines (I.e. Google, Bing and Yahoo) have an issue with my pages remaining in a sub folder for indexing? I use Yoast SEO plug-in and find it quite handy. What do you think? Thank you.

  125. I just wanted to say THANKS for these clear, easy to understand instructions. I am no web developer, but manged to follow these instructions and get my site working in the right directory. Thanks for the help & advice!

  126. THX this worked out (and with having to do the .htaccess and permalinks). However, I have a few “private” pages so they dont show up in the main menu as parent/childs and text linked to from pages (to “read more” type of thing). Under the new naming redirect (to main root like other pages) these show up as “not found” pages, but you can see them if you manually type in the ‘old address’ with the subdirectory (i.e. dev.sitename.com/private vs. sitename.com/private). I appreciate your time.

  127. How can I upload a new theme to my multisite wordpress-Always come up error/css style missing. I also tried uploading to my filezilla. still doesn’t work. Please help. I really don’t know, what to do. Thank you.

    • Make sure that your actually uploaded the full theme folder rather than the zip version of the file or the full theme files rather than just the actual folder containing the theme. What theme are you trying to upload? You should see an index.php, style.css plus other files in that folder.

    • Make sure that your actually uploaded the full theme folder rather than the zip version of the file or the full theme files rather than just the actual folder containing the theme. What theme are you trying to upload? You should see an index.php, style.css plus other files in that folder.

  128. This worked for me:
    1) Using FTP, copied index.php to my computer, then copied index.php to the root directory of site – /web , in my case
    2) Under dashboard//settings/general:
     WordPress Address (URL) – left ‘as is’, pointing to /web/wordpress folder
     Site Address (URL)           – changed to site homepage (different from WP folder files)

    Had issue with site still pointing to old home page.
    3) Renamed index.hm to old-index.htm – it WORKED! 
    (index.htm is first place that code looks  to establish home page, so this MUST be renamed so index.php can be accessed first) 

    Minor wp-admin issue occurred – could not login to site, so had to add /wordpress/wp-admin to site name for site updates (wp-admin file is still under wordpress files, not root directory) Will leave this way for the time being.

    Thanks WordPress Girl – this was a big help!

    • When you login after completing my steps EXACTLY, then you will ALWAYS still login via the URL that is the sitename/subdirectoryname/wp-admin because that is where WordPress is installed. As part of this process, you do NOT MOVE WordPress, you are simply having the URLs for posts and pages display from the root instead of the subdirectory. All the images, uploaded files, themes, plugins, wp application, etc. are still in the subdirectory. Does that answer your question?

  129. AskWPGirl – you are an amazing find! Thank you so much for this easy to follow guide – you saved me hours of frustration and fright! :)
    I followed the instructions above however – I seem to be having an issue with a link.
    I did a trial run of the migration (changing from paulsonbrothers.com/wordpress to paulsonbrothers.com). Everything looked great, except … when i click on OPTIONS in the menu, it takes me to the correct page, however, when i try and click on any of the other menu options (BATH, KITCHEN, etc) it errors out with ‘404 PAGE NOT FOUND’ i did notice for some reason it wants to reference the original link; paulsonbrothers.com/wordpress. is there a way for me to fix the link? i did update the permalinks – but this did not fix the issue.  thanks so much for your help!

    • Did you copy or move the index.php file to the root directory for the site and modify it per the instructions I sent? If you did not do that, then the URLs will not work. You have to follow all of the steps in the post. If you skip a step, then there are problems. Also, your .htaccess file may need to be moved to the root as well. On one web host I work with, the URLs give 404 Page Not Found if the .htaccess is in the subdirectory. Check the .htaccess to make sure it doesn’t contain the subdirectory in it. Also, you will need to get rid of the current pages on the site so they don’t conflict with the WP urls. You can’t have both index files in the root. So, please follow these steps, then if you want to hire me to help you, please contact me via my contact page at http://moongoosedesigns.com. Good luck!

  130. Hi. I have default WP installation. With no content other than the example content. It was installed by default in /wordpress. I want to move it the root of my domain. I have the index.php file correctly changed. I have the .htaccess file with the correct information in it. Yet going to my domain site http://www.anlarye.net I am prompted to download a file named ~ and nothing more. Everything that I can see appears to be done correctly.

  131. Great! All fine except that the images do not show up on my pages.
    I can see the img src is set in the root directory, but the images are in wordpress directory.

    Any clues on how to fix this please?

    Thanks so much, this is exactly what I was looking for. 

    • When using my instructions, you do NOT change the img src location. The reason this process is simple, is because the image links do not break. However, if you manually changed these, then they will be broken. The images still exist in the wp-content folder that still exists in the subdirectory. So the url to the img src should include the subdirectory.

  132. Hello, thanks for your info it is very useful. Right now i am finishing my website redisgn using wp which is installed in a subdirectory (while the old non-wp site runs at root). As you mentioned, keeping the site under a subdirectory has a lot of advantages, but does it have any negative impact in SEO? Is it worth in SEO terms to move the site back to root instead of keeping it at a subdirectory? Thanks a lot and regards from Mexico!

    • Keeping the WordPress installation in the subdirectory while having all of the posts and pages displaying from the root directory does not impact SEO because the pages and post URL all display from the root. Only the WordPress application functions are in the sub-directory along with the uploaded images. After you go live with your site, install the Google XML Sitemaps plugin and the All in One SEO Pack (which should have a sitemap built into someday soon) and get those setup properly. Sign up for Google Webmaster Tools and submit your sitemap. You might want to install the Redirection plugin to redirect your old site URLs to the new site, though I recommend turning off the option in the plugin to Monitor WordPress Posts, because that inevitably causes crazy issues.

  133. Hi I had a site in a subdomain, thought or read that you should just change the site url and the wordpress url to the main domain, did this thinking I could change it back if it didnt work, now the site has many 404, and links and theme template has disappeared completely.
    Can it be rectified, or do I, or should I un-install it and do a complete rebuild.

    http://aikidoports.aikidoinportsmouth.com/ 

    Cheers TOny

    • Hi Tony,

      My instructions apply ONLY to WP sites installed a sub DIRECTORY or sub FOLDER, not a sub DOMAIN. Subdomain works differently and will not work following these instructions. To restore visibility and access to your site, you will need to login to your database with phpMyAdmin and modify the URLs for the site and the home (see the FAQ for this blog post) and change it back to your subdomain URL for both.

      To have your subdomain be your main domain, you can ask your web host to point your main domain DNS to the subdomain directory, then change your General Settings to use the main domain url in both fields and use the Search & Replace plugin to replace the old subdomain URL with the new main domain URL for all the uploaded image content and internal hyperlinks.

      • Thank you WpGirl
        I see the error of my ways ha ha, thats a big help, thanks for your advice and time, 
        will try what you suggest and see what I can find

        Cheers Tony xx

        • Hi Tony – I should definitely emphasize that at the top of the post and perhaps write another post on the subdomain transition. It’s a bit challenging, because web hosts handle subdomains differently.

  134. Thanks for the great tutorial! I was having an issue where all pages but the home page were showing up. I read through your FAQ page, and the culprit was some old index.html files alongside the index.php. I archived the .html files, and everything’s working now.

    I appreciate your great work.

  135. hello, I also have WP installed on a subdirectory (www.websiteaddress.com/WPsubdirectory). I have created a multisite network and am trying to create a new site at http://www.websiteaddress.com. I am only able to create a second site if I create another subdirectory under http://www.websiteaddress.com. What am I missing? I can I create a site at the root directory when WP is installed on a subdirectory already and powers a website under the same subdirectory. I am new at this so perhaps this is bad design to begin with…Please redirect me gently :-) Thanks

    • Hi Joelle,

      It is not clear to me WHERE you have created your multisite network and what you are trying to accomplish or how you have your multisite set up. Multisite is very different from the regular WordPress and the multisite network could interfere with your installing other versions of WordPress in other locations if the URL relates to your other networked site URLs. Also, multisite will NOT work installed in a subdirectory and redirected to the root. For multisite to work properly for subdomains, it should be installed in the main URL of the site.

  136. Hey this is brilliant, however i have another question
    i have a wordpress installed in a subfolder and i have an HTML file in the root which contains flash site, i then i have a link in there which points to the wordpress site which is in the subfolder

    i want to be implement this same thing as above while maintaining the flash site in the root

    is it possible

    Thanks
    Antony

    • Hi Antony,

      That’s a great question. So, you want to display all the WordPress URLs from the main URL but keep the Flash in the root, correct? The main issues I would see with this are:

      1 – Is the Flash file invoked via an index.html or some sort of index file that would conflict with the WordPress index file?

      2 – Is the Flash file the landing page for the domain? If it is, then having the WordPress index.php file in the same directory may conflict.

      3 – You said the Flash site points to the WordPress which is in a subfolder. If you resolved 1 & 2 above, then you would need the Flash link to point to the new URL for the WP page you are wanting it to go to after following the steps in my post.

      You could certainly backup your WP site using a plugin like BackupBuddy (http://askwpgirl.com/go/backupbuddy.php – my affiliate link) and then try the steps in my post and see if it works. Not knowing the name of your Flash file and whether that is the home page of the site is a bit tricky. However, being a resourceful person, I would follow the instructions in my post, then create a blank php page template within WordPress (eg page-flash.php) and assign this page template to a new page in WordPress called “Home” or “Splash” and choose this as the Static Home Page under Reading Settings. In the page-flash.php template, I would put the code to launch the Flash.

      If you don’t know about creating custom WordPress page templates, this might be Greek to you, but it would be one way to keep the Flash functioning and WordPress at the same time from the root, by incorporating the Flash into the WordPress install. It won’t change the look of the Flash, it will just make it behave from a URL standpoint properly by being an object on a WP page (that is — a totally blank WP page so it doesn’t disrupt the look/layout of the Flash).

      • thanks for your response

        Hey the flash file is evoked using the Default.html file, which has precedence over Index.php right ?Yes the Flash is the landing page for the Domain, the landing page has an enter here which redirects to the wordpress site, the URL for the link is given as wordpress/index.php

        so i should be able to do your procedure as long as i have the landing page as default.html and of course i have to point the enter here to /index.php right ?

        if you want to have a look at the site here it is 
        http://shalimarthailandplants.biz

        • I’m not sure if the default.html will conflict with the index.php. I think it will, that’s why I would personally create a page in wordpress called “home” or “flash” and make this the default home page for WP under General settings, then create a custom page template that basically has the contents of your default.html page on it. If you want to hire me to set that up for you, I could.

          • you might be right, i default.html does conflict.
            i am going to try the custom page template, if i fail i shall get back to you.

            thanks WPSupergirl

  137. Thank you soooooo much!  I have followed your instructions and all worked well except I can’t get the home page navigation link to work.  Have installed plugin, looked over code and still can’t make it happen.  Any thoughts would be very much appreciated.  I was in Boulder for the last Word Press Camp there.  Enjoy your day, Bob, up the road in Lander, Wyoming

    • Hi Bob,

      The home page link is either set in your theme’s header.php file OR more likely under Appearance > Menus. So you probably want to remove the Home like you created previously for your custom menu and add a new custom link to the home page and save your menu.

  138. This is exactly what I need to do, except when I try to do it, I am getting the following error when I load the main “mysite.com” page:
    “Warning: require(./wp-blog-header.php) [function.require]: failed to open stream: No such file or directory in /home/hihp0312/higherhopechurch.cggc.org/index.php on line 17

    Fatal error: require() [function.require]: Failed opening required ‘./wp-blog-header.php’ (include_path=’.:/usr/local/lib/php:/usr/local/php5/lib/pear’) in /home/hihp0312/higherhopechurch.cggc.org/index.php on line 17″
    There was a previous Joomla installation and there is no www, htdocs, public_html, or httpdocs folders that I have unearthed after hours of searching. I thought I had the file in the right root directory, but perhaps I don’t. Any help you can provide would be immensely helpful. Thank you. 

    • Hi Jen,

      You may have missed a step. Please read the FAQ for this blog post and check that you edited the index.php file correctly after you moved it to to the public_html directory. Please reread the instructions carefully. The error you are getting is related to the index.php file not finding the folder in which you have WordPress installed, and the require line must be edited correctly according to the instructions in the post.

  139. this is still very complicated, compared to what was said about moving one file, one line of code and one modification!  I might need someone to hold my hand while I do this because those instructions are foreign to me lol

  140. THANK YOU, THANK YOU, THANK YOU!!! If it weren’t for passionate individuals such as yourself… where would we be???
    :-)
    Your assistance has been greatly appreciated!! Bonnie

  141. Hi,
    Thank you for the above instrusctions. They’re detailed and will certainly assist me. However, I seem to have ‘lost’ my old static site. It’s no longer in the public_html folder but somehow is still live. :-) help!!
    Thanks
    Bonnie

    • I don’t know what you mean be “is still live.” Does that mean you’re finding it in a Google search or you see it when you visit the site in your browser window? Have you tried deleting your browser cache? It will take a few weeks for Google to re-index your site and no longer show the old page URLs. It helps if you install the Google XML Sitemaps plugin and submit the sitemap via Google Webmaster Tools.

  142. On my win2003 server with PHP5,  I was getting a white page for my blog until I changed the line in the index.php file at the root of my site (not the index.php file in the blog directory) to the following:    Note the deletion of the “./” right before “mywp”.  It’s working great now.

    • Your text got cut off in the comment, so I don’t know what you changed your index.php file to, but yes, you are supposed to edit the index.php file in the root of the site not in the sub directory. The copy of the index.php in the subdirectory doesn’t have a function after this process has been completed other than to prevent reading of that directory.

      I have never seen the index.php work properly without the ./ before the sub-directory name. That wouldn’t make sense in a normal hosting environment. Here is what the require line is supposed to look like (where blog is the name of the subdirectory):

      ‘./blog/wp-blog-header.php’

      So, interesting that yours is working as:

      ‘blog/wp-blog-header.php’

      on your server. I would think that would break it unless there has been a typo to begin with. I don’t know anything about Windows server hosting. I usually recommend people avoid hosting their WP on Windows because it usually results in a lot of problems, including difficulty with permalinks and plugins.

  143. I have been looking for an answer for my question and I think I found it or near enough but need some clarification first. Right now I have a static html site that I host on Hostmonster and currently use WordPress for my blog so it’s already installed. I would like to remove all the old files and create a new website in WordPress (all new pages, nothing from the old site will be kept) but keep the blog content as my blog. I have installed a new theme and am ready to design.
    When I am ready for my website to go live I will remove the old html pages from the root directory, follow steps above to move WP from sub to root directory and deactivate the maintenance plug-in. All things being equal everything should be cool. Since I am moving WP to the root directory will my blog still be my blog and my website be my website on the WordPress platform? Or do I need to do other steps?

    • Hi Grace,

      Is the only WordPress you have installed the one in the sub-directory? It sounds like you might have two WordPress installations. Please let me know then I can advise you.

      The easiest thing would be to just use your current blog WordPress installations and create the static pages on that installation of WordPress using the new theme, etc., but then, if you’re using the maintenance mode plugin, people won’t be able to see your blog. That’s why it sounds to me like you are working with two different installations of WordPress.

      • I think you might be right. Under the public_html there is a blog folder that includes wp-admin, wp-content and wp-includes. 

        In the public_html/RedBarn-Studios folder (where my current & soon to be old website files are) there is another folder called blog_2. If I remove this whole folder (RedBarn-Studios ) completely I assume that the blog pages I have designed will be deleted as well?

        • Hi Grace,

          I don’t know how to advise you at this point, since I don’t know which WordPress install is being used for your content, and it actually sounds like you have 3 copies of WordPress installed. If you want to hire me to sort this out for you, I can be reached at http://moongoosedesigns.com. Do you have two or three WordPress logins you are using – one for each of the sites? If you do, you need to pick the one you will ultimately be using for the live site, and login to the other one that contains your posts and go to Tools > Export and export all of your post content and then go to Tools > Import on the version of WP you want to use when you’re all done with your development and import those posts, so you have everything in one place. Don’t delete anything until you’re positive you have ALL of your content in the correct WP install. I have seen people do this before. They sort of get carried away with the one-click installers at their web host and forget all the places they’ve installed WordPress as they attempt to development work on a new site.

  144. Angela – as always, thank you for your simple instructions

    I was able to get this to work on a site of mine before, however, the WordPress contents interfered with some ASPDotNetStorefront contents, so it was either/or (by switching out .htaccess files)

    However, we have now MOVED all of our ASPDNSF contents to a subdomain/subdirectory “store”, and the root is completely clean except for 4 directores

    And now I want to complete my original intention of having my WP contents show up as domain homepage and normal pages

    I got the homepage to load, and nav links are written correctly (without the /subdirectory/ showing in the link)… BUT I get the “”The system cannot find the file specified”” error when clicking onto navbar links to inner pages

    I made sure to MOVE .htaccess over from subdirectory to root, and to re-save my permalink settings, but no go

    Im thinking it has to do with me not doing exactly how I first tried (when successful) and possibly regarding COPYING vs. MOVING the index.php file and/or the .htaccess file

    Just to be sure, I am supposed to essentially have TWO index.php files, one at root and one inside subdirectory where all wp contents are… correct? and with that, should those index.php files be identical? Im guessing they shouldn’t since your instructions say to download original, edit, then upload edited to the root – so it should be like this right?:

    index.php in root should read:
    require(‘./blog/wp-blog-header.php’);

    index.php in subdirectory should read:
    require(‘./wp-blog-header.php’);

    I also tried the Silence Is Golden index.php within the subdirectory – still no go

    I also tried having the .htaccess file BOTH in the root and subdirectory, made sure to update permalinks settings. Nothing.

    Any ideas?

    It might be something entirely different, being as this is a clients site hosted on a Windows host (booo! but he is running .aspx so must)…might be something else interfering

    However, I was able to get it to work BEFORE, when the aspx stuff was at root, so I figured that after moving it to subdomain and root being clean as a whisle, that the WordPress would work perfect 

    thanks so much for your input

    • Hi Jesse,

      Are you hosting on a Windows server? It sounds like you are if you’re also hosting an ASP store. If you are on Windows, you will need to contact your web host about how to manage the permalinks, because .htaccess with the rewrite mod is an Apache server function, not a Windows server function. If you read my FAQ which is linked at the bottom of this post, I do have some info about Windows permalinks on there.

  145. found it further down on your blog. my .htaccess file wasn’t writable and I had to save it manually.  i all works.  thanks for your WP mojo!

  146. Thank you for these tips! I moved everything over and followed your instructions.  The landing page loads fine but the interior pages are not showing. I move the .htacces file to my root. I opened up my .htaccess file and there’s nothing in it.  It’s file that was installed with WP by my host.  I guess there should be some redirection code in there but I’m not sure what if anything. Thanks for any light you can shed on this.  

  147. Thank you for your prompt response.

    After a bit of googling I found the relevant WP Codex page (http://codex.wordpress.org/Linking_Posts_Pages_and_Categories) to say “If you have installed WordPress to a subfolder, such as wordpress, don’t forget to add the folder to the link URL”. That is precisely what I have had to do, so perhaps I’m stuck with it!

    Cforms survived the procedure with no problems despite your dire warnings. I’ll investigate further about the password plugin, but maybe I’ll have to abandon that one.

    Many thanks; great post!

    • When you follow these procedures, the URLs for categories, posts and pages do NOT include the subdirectory. However, when WP is installed a subdirectory, as I wrote before, all of the images and uploaded files DO need to include the subdirectory in the URL, because the wp-content folder has not moved — it is in the subdirectory.

      • I should add that for people who follow these instructions precisely from the beginning and haven’t done other things previously to change the links on the site, then they do not have to worry about any links being broken, except for manually created internal links to pages or any custom links in the Appearance > Menu.

  148. Thank you! After hours of trawling through numerous over-complicated instructions and laboriously undoing all the changes I had made when they didn’t work, I came across your clear instructions which made sense, and worked first time. However, I still have a couple of problems………

    My links to uploaded media files such as pdf files were broken and I could only get them to work if I manually re-inserted the subdomain name into the link realtive URL. This worked, bit is there another tidier way to restore these links?

    More importantly, in my subdomain I had a plugin called Exclusive Password Content Protect which hides certain content unless a password has been entered. The password entry box still shows, but entering the correct password achieves nothing. Any suggestions?!

    • Hi Henry,

      Not knowing what you may have done or not done to break your links, I can only say that:

      1) This process will NOT break ANY image or uploaded file links.

      2) If your links are broken, it’s because of something you tried to do previously to “move” WordPress and perhaps rewrote your links in that process.

      3) If WordPress STILL resides in the subdirectory, then all of the images and uploaded file links should still contain the subdirectory in the URL, eg. http://askwpgirl.com/subdirectory/wp-content/uploads/mydocument.pdf

      As far as the plugin again, the same applies there — it should work fine but some plugins don’t have the paths defined correctly and insist on looking for WordPress in the site URL rather than WordPress URL, so that would need to be changed in the PHP code of the plugin if that’s the case. You can Google that plugin and see if people have issues running it from a subdirectory. Cforms has this issue as well.

  149. Hi, I am working on a new wordpress site that I will eventually move to my main domain name to replace my old static site. Your instructions on moving it are very helpful, except I have one problem: I can’t find the line  any where, on my index.php or on any of the index.php files that are with some of the included themes. What do I do or where do I find this?

  150. Hi Christopher,

    I use HostGator a lot. The issue with the .htaccess is easily resolved by going to Settings > Permalinks and clicking the Save Changes button. This automatically rewrites the .htaccess file after you’ve done the “move.” This is not a HostGator specific issue. It’s more that sometimes your .htaccess needs to be rewritten and the simple Save Changes on the Permalinks page will do that on good hosts such as BlueHost and HostGator.

    Good to know about the Silence is Golden Guard plugin. I assumed it created an index.php in the WP directory, but if it doesn’t then I shouldn’t recommend it here and instead people should just download the blank index.php file from the wp-content and upload that into the WP directory — or WordPress recommends copying and not moving the index.php that’s there.

  151. You have the site installed in a subdirectory and when you to go the root URL you want it to REDIRECT to the subdirectory, so you really DO NOT want the URLs to display from the root, you want them to all display from the subdirectory and when you go to the home URL you want it to show the subdirectory not the root URL? Correct? If that’s the case, return your Site Address (URL) back to how you had it with the subdirectory name and then use .htaccess at the root to redirect the root URL to the subdirectory.

    You are doing the opposite of what most people want to do, so you should not follow any of my instructions in this post and instead leave everything in the subdirectory and use .htaccess redirect the root URL to the subdirectory URL.

    Most people want to get rid of the subdirectory in the URL and show all the links from the root, so that’s why my post is not helpful to you.

  152. Hi Angela, I have a different problem that I hope you might be able to shed some light on? When I first installed wordpress I did so on a subdirectory. Thinking I knew what I was doing I then copied this folder to my root to make this my websites directory. As your post so eloquently illustrates this did not work. So I resumed using the subdirectory as the root of the site. The site has grown in time and uses many plugins. I now want to consolidate the site and get rid of the extra files that were made by my previous attempt. The thing is, the site seems to use some of these files. So when I delete these extra files on the root of the server it breaks the site, even though the sites root is in a subdirectory. Is there a way of finding out which files the site is using in this directory, so that I can consolidate the site and then move it using the method you have written?

    • Either the site is in the subdirectory or it is in the root. Now you say you have files in both the root and subdirectory. That doesn’t make any sense. WordPress will look in one location for the files, so you should check your Settings > General in WordPress and see what those are and write back. Also, see what is in the index.php file. Why are there any files in the root if you moved them all back to the subdirectory?

  153. i want to have my site which is installed at http//www.optimasystems.ca/security_division  wordpress is installed in this location as well as my theme. it works prefectly but i want it so that when you type http://www.optimasytems.ca it shows the new wordpress site in the security_division folder

    Your instructions seem so simple but  i keep getting
    this:

    Not Found
    The requested document was not found on this server.

    so i changed the index.php file to this
    ———————————————————

    this index.php file is a copy which was in the folder security_division

    i also changed my general settings to:

    WordPress Address (URL) http://optimasystems.ca/security_division

    Site Address (URL) : http://optimasystems.ca

    so i belive thats all i have to do but it’s not reading anything.

    i have the old site up and changed the index.htm file to indexold.htm just so it wouldnt get confused . i put it back because the owners woulud freak if they see no site up.

  154. Thank you for this post. I carefully followed the instructions and got it mostly working first time. I was using it to convert an old static site into a WP site, and I wanted to learn how to install WP in a directory.

    My problems came from the fact that I use Hostgator. The site would not work internally with WP generated .htaccess file not in root (public_html). But when you move it to root it still has the reference to the installation folder in it. I edited in TextWrangler and uploaded it to the WP subfolder then copied over the top of the generic .htaccess that is created by the hosting. Bingo, everything worked.

    I tried the silence is golden plugin, I must be dense because I could not get it to create an an index.php for the the WP folder, but it seemed to create one everywhere else. I ended up just doing in TextWrangler and uploading using my host’s file manager program.

    Overall, a good experience, and I think I will do all my WP fresh installs in directories, not in root. Thanks.

  155. Excellent, straightforward steps. Something I was worried would cause me a headache was completed in a few minutes thanks to these instructions.

  156. You are a life saver…so far! I’ll check back in 10 minutes to see if it’s still working…

    Your directions are VERY COMPLETE and easy to read. Thank you!–Ana

  157. PERFECT! Easy to follow instructions that Ditto shannon.

    I do have one issue, which began on my first attempt at this from another person(ugh) None of my images are showing up. The place holder is there and the link at the bottom display the original path to the image but no workie :( Any suggestions?

    • Hi Maria,

      It’s hard for me to say what the problem might be because of someone else having gotten in there, and we don’t know what they did. You can read the FAQ I wrote on this process, but I’d probably need you to send me the URL to the site, so I can see what’s going on. Are you still accessing WordPress via the sub-directory? What are the URLs to the images?

  158. Thank you so so much!  This saved me so much time and now I am going to create all of my sites in a subdirectory.  Do you know if I will run into any problems in I install a wordpress landing page in the root, and then delete all those files before I go to move the fully developed site from the subdirectory to the root?  Thanks!  I’m off to make a donation for your excellent help!

    • Hi Kimberly,

      Thanks for the donation! You can use one of two plugins (see below) to create a temporary “landing page.” You’ll want to follow the instructions in this post first, though, so the landing page plugin works. Otherwise, it will just show up in the sub directory.

      When you’re ready to go live, you’ll simply disable the plugin.

      http://wordpress.org/extend/plugins/underconstruction/

      http://wordpress.org/extend/plugins/custom-coming-soon-page/

      You can try them each out and see which one you like better. I think they each allow you to specify a custom-designed html page or have options for styling their landing page.

      • Thanks so much for that advice.  I will take that into consideration on future creations.  For my current site, however, I already installed a landing page plug-in at the root (along with a wordpress install), but I am working on my actual site on a subdirectory.  I’m wondering, is having an install of wordpress at the root going to cause any problems when I go to make the transfer?  And do I just delete all the files in the root at that time to make the transfer?  A little clueless.  LOL. 

        BTW, your advice from this blog post worked beautifully for a site I was just working on for a client!

        • You are so smart! For the site where you have WP in the root and WP in subdirectory, you’ll want to delete the WP in the root and then follow the steps in my post.

          You might have to go to Settings > Permalinks to save those again so the .htaccess in the root gets reset properly.

          Glad everything worked out with the other site! The only problems I’ve seen are with extenuating circumstances — such as Windows hosting server, mistakes, and people leaving their old files in the root.

  159. I’ve got a lot of subdirectories on my site for forum and CMS applications and had previously linked to these from a static webpage in the root directory. This is so much easier and neater. I like the clarity of your instructions and the layout of the site.
    Thanks for your work.

  160. All I can say is… THANK YOU! I must have read every tutorial on this topic over the past three hours and no matter what I did, I couldn’t get it to work until after reading yours. It was your well-written, highly-stressed #FOUR tip that solved this problem for me. Because I named my sub-folder wordpress like so many people do, I was actually changing the /wp to /wordpress, instead of just adding it in front of the slash. Blame it on my tired eyes or maybe not paying enough attention, but you spelled it out so beautifully and made it easy to  see what I was doing wrong. This was my first time designing a WP site to take over a client’s static html instead of starting from scratch, and I was already a little nervous about the process. With this info I will definitely be leaving the WP files in a sub-folder from now on to keep things nice and neat. Thanks again for making it seem less scary! I will be bookmarking your site to follow for the future! :o)

    • Hi Shannon – That was the best written testimonial I’ve received yet! I’m glad that the highly stressed #4 was helpful. After receiving hundreds of comments on this post and helping people personally do this, I’ve rewritten the post plus wrote an FAQ, because I would see the same mistakes over and over again. It’s those simple things – like syntax – that can make things go wrong. I’m guilty, too, of “tired eye syndrome” and simply having a misplaced ; or ‘ in my code. Good luck! I’ll be writing more helpful posts over time.

    • Nice to meet you, Brenda. I hope to write more soon. I’ve discovered some awesome WordPress themes that make development so easy that I’ll write about along with how to migrate WordPress to new host or from development site on a local computer to a new site, etc.

      Angela

  161. Hi Amanda,

    I use Gravity Forms on just about every site I create, and I’ve never had this problem. If you think it’s the Silence is Golden plugin, then de-activate that and just make a copy of the index.php file you find in the wp-content folder and put that in the root.

    I don’t think the Silence is Golden Guard plugin should cause this problem, but I do know someone else who had some weird issues and we disabled it as a result.

    Check over all your settings again just to be sure you didn’t leave a forward slash at the end of your URLs in the General Settings. Email me via my contact form at http://moongoosedesigns.com if you still have trouble.

    I would perhaps suspect more greatly that you need to clear your browser cache and perhaps you should reinstall Gravity Forms — perhaps you updated it at some point and one of the files didn’t update all the way. One person who wrote to me had issues she thought were related to this “moving” process but were really because she had just updated a plugin, and the update didn’t completely properly.

  162. Hi Angela, Your way of explaining this process is fantastic, I have used it numerous times with absolute success. I have come across a problem with a site I am working on currently, within a plugin – Gravity Forms. All the internal hyperlinks, images, everything, works perfectly from the subdirectory install for every other plugin and image. Except within one area of the  Gravity Forms plugin which is a link to a modal window from with the plugin dashboard.  It returns the white screen (as as I have Silence is Golden running). If I don’t have Silence is Golden running then the sites index is listed. This modal window is meant to be a editing window, like a image edit window. I have been in touch with the Gravity Forms Developer, but they seem to think its the install? Have you come across any issue like this before? maybe have some tips?

  163. Can I still tweak the site (the theme options, for example) and add pages and posts after I’ve gone through the process above?

    • Hi Lily,

      Yes, it will work exactly the same as it does now. This simply allows the URLs to show from the main URL of the site, but WordPress is still in the sub-directory, so you will access WordPress via the same URL do now.

      ~Angela

      • Hey Angela, Thanks so much for the quick reply. I actually went ahead and did the process myself and saw that it is indeed editable. All went very smoothly, perhaps because i followed your directions to the letter. They are so well written. A million thanks!

        BTW, I’m “Angelynn” and you can see my site now at http://angelynngrant.com.

        I’m going to make a donation in gratitude.

  164. Thank you for the great post. I had a similar issue and helped me but now  i see another problem. i cannot access my posts via the menu and get white/blank pages..any idea how to fix this?

  165. Angela, great post, really, thank you very much. You can tell how good a post it is by how many comments it receives WAY after it’s been posted! You wrote this a year ago people are making use of the info to this day! This guide really freed me up with a client; thanks again.

    • That’s awesome, Daniel. Thanks for the comment. I have been keeping the post updated since I wrote it, and also wrote an FAQ based on all the comments. It’s amazing how many hits it gets, and I know people get really stuck with this and have some urgency, so I try to be responsive. I might make a little video! I also am in the process of writing a post about how to migrate WordPress from one server to another using BackupBuddy.

  166. WOW!  This is awesome!  It worked just like you said.  Now, is it possible to move the ‘image’ directory by itself to the root to completely protect the location of the install?  Thank you for all the help. :)

    • I did read a post somewhere (perhaps on Perishable Press) about being able to locate the wp-content and/or uploads folder to a different location, but it didn’t always work with specific plugins. So, I wouldn’t take the chances. It’s so easy for bots to find out “where” WP is installed, that it’s hard to totally obscure it and your site, if it gets hacked, is going to get hacked via a plugin or theme NOT WP core. The best you can do for security purposes is to be cautious about what plugins you install, keep everything updated all the time, and do regular backups of your database and wp-content folder using a plugin such as BackupBuddy (my affiliate link: http://askwpgirl.com/go/backupbuddy.php). Glad the process worked!