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).
- If you feel a strong need to actually MOVE the WordPress installation from the subdirectory into the public_html folder, I’ve written instructions for moving WordPress from the subdirectory to the root directory here.
- If you installed WordPress in a subdomain (e.g. you can view the site via an address like http://dev.askwpgirl.com instead of https://askwpgirl.com/dev), then please see Moving WordPress from a Subdomain to a Root Directory instructions. They are similar instructions by slightly different.
Installing WordPress in a subdirectory can be a good idea because:
- It keeps your root directory clean and tidy (in case you need to add any other PHP applications to your site).
- It adds a layer of security through obscurity by obscuring the location of your WordPress application files. Ideally, you want to name the subdirectory something not too obvious (ie don’t call it wp or WordPress). I’m not sure how obscure this really makes WordPress, because you can obviously get the subdirectory name from any images uploaded to the site, since they will still read as 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.
- It allows you to develop a new WordPress site while maintaining your current website in the root directory. Once you’re finished with your WordPress development, you can backup and then delete your current site’s files, and use the following instructions to display WordPress from the root directory of the site.
Note: If this is an older site, you will need to create 301 redirects to redirect your old page/post URLs to the new page/post URLs. Also, if you have a lot of internal hyperlinks, you will need to manually update those.
Before attempting to move WordPress
a) Clear ALL pages cached by your caching plugin cache AND then de-activate the caching plugin. Also, de-activate Broken Link Checker and any Redirection plugins;
b) Remove any old site files from the root directory — perhaps copy them to a folder called _backup – this includes an index.html file which will totally make this process not work. You MUST remove all those old site files and folders or move them into another directory, so they don’t interfere with WordPress. Having an index.html and index.php in the same folder causes confusion, and likely, the index.html will be used instead of WordPress’ index.php file;
c) Make sure you don’t have any other folders in the root directory that have the same name as any pages on your WordPress site, for example “blog” unless of course this is the name of your subdirectory install of WordPress in which case you cannot have a page of the same name because the browser will get confused and look for that page in that folder, then things are really confused;
d) Use wp-db-backup to make a backup of your database – 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.
Displaying WordPress URLs from root directory when WordPress is installed in a sub directory
1. Login to the WordPress Dashboard. From the Settings -> General tab, set your WordPress address URL to the subdirectory you installed WordPress in (without the trailing slash). Note: This will already be displayed in the WordPress address field, so you don’t have to change it. What you do need to change is the Site address URL. Set this to your site’s root address (without the trailing slash).

2. Using an FTP application or your web host’s File Manager, DOWNLOAD the index.php file that is in the WordPress application directory (not the one in your theme’s folder or elsewhere) and then UPLOAD the copy you downloaded to the root directory. (By root, I mean the www, htdocs, or httpdocs folder — NOT the root of your hosting account! You simply want to upload the copy of the index.php file and put it in the parent folder of your subdirectory which presumably is the location for the main URL of your website.)
Alternately, you can use your FTP application and MOVE the index.php “to the parent” but then you MUST read and follow step 6 below.
(Note: If you have a site already in the root directory, such as an old static html site, then you should backup and delete those files first.)
3. In a text or HTML editor, open the index.php file that you just copied and/or moved to the root (aka main url) directory and change the location of your wp-blog-header.php to tell WordPress where it can find the WordPress application files in the subdirectory:
Example: if your WordPress installation folder is ‘mywp’, you would change:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
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.
4. Visit the site and click an interior page to make sure it displays correctly. If it doesn’t, you may need to update your permalinks (Settings -> Permalinks and click Save Changes). If you still cannot access your interior pages, then the .htaccess may need to be moved to the same location as the index.php file (i.e. the root directory). This is not necessary on all web hosts. Be sure to update the permalinks again after you move the .htaccess file.
Remember that your login and registration links will still be 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, 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.
5. Create a “Silence is Golden” index.php file in the WordPress directory.
If you copied the index.php file instead of moved it, this step is optional. Essentially, you don’t “need” this duplicate index.php file in the subdirectory because it doesn’t really do anything other than prevent people from reading the directory contents. However, if you moved the index.php file leaving the WP directory without an index.php file, then you should create a new blank index.php file and put the following code in the file:
[php]<!–?php // Silence is golden. ?–>[/php]
Problems?
If you have any trouble with this process, please visit my Moving WordPress from Subdirectory to Root FAQ.
Success?
If this process was successful, please comment with a thumbs UP below, share on Twitter, follow me on Facebook. Thanks!!!




Totally worked! Thank you SO much!!!
Thanks, this was too easy.
wow awesome thank you that was so much easier and actually what I preferred then doing it the way WordPress documents suggest.
Yay! I’m glad it worked!
Perfect! Thanks a lot!
I could kiss you!
Worked Awesome! Thanks!
You’re the BEST! Been tweaking dns, forwarding, masking, etc. Just tried your fix & :02 later, I was back in business. Thank you, thank you, thank you!
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
Thanks! This really got me out of a pinch today!
Remember that your login and registration links will still be http://www.yoursite.com/mywp/wp-login.php.
what if we want the login and registration links to be http://www.yoursite.com/wp-login.php as well ?? HELPPP !! thankssss !!
If you want to login to WordPress not using the subdirectory URL, then you need to MOVE WordPress into the root which is a different process than I what I describe here. I think the best way to do this is by using BackupBuddy plugin – my affiliate link is https://askwpgirl.com/go/backupbuddy.php
They have great video tutorials. Or you can follow these instructions (which might result in more broken things than using BackupBuddy):
http://codex.wordpress.org/Moving_WordPress#On_Your_Existing_Server
You could also add in a RewriteRule in .htaccess.
I’m wondering if the RewriteRule in .htaccess would create problems since WordPress actually lives in the subdirectory and all of its application files are there that will be sought in the subdirectory.
It worked! Thank goodness for this post.
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!
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.
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!
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.
Thank you!!! Worked like a charm!! 😀
Thanks so much for your clear explanation. This made it super easy!!!
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.
Worked like a charm. THANK YOU!
Brilliant and clear explanation – many thanks
 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
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!
Looks like you got it to work.
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!
Yay!
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.
 Thank You so much for your excellent answer to this question! I’ll be working on this as soon as I put out some other fires.
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.
Better WP Security. It does include a Silence is Golden Guard. I’ll look into that.Â
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
Good to know, thanks!
Thanks again for the recommendations. A couple of those haven’t been tested on the latest version; I’ll use what I can, but stick with known quantities.
Easier than the way I did it in the past! Thank you!
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
Nice – thank you!
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.
Thank you for the quick reply! Â
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!
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.
Oh wow!! Very easy and so awesome!!! Thank you!
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.
thank you, thank you.
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!
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.
Thank you very much! Your a life-saver!
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.
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?
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!
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.
It looks like you got things up and running. I would recommend BackupBuddy plugin for reliable backups. Here is my affiliate link: https://askwpgirl.com/go/backupbuddy.php
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.
Thank you WPGirl for making something less-complicated… 🙂
🙂
EXCELLENT! Very easy to do and works like a charm! Happy Dance!
Every now and then, it’s nice when things aren’t hard. 🙂
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.
Angela,
That worked absolutely perfectly. Â Thank you for taking the time to write this tutorial. Â Well-done, complete and easy to follow.
Thanks.
– Troy
Hi Troy, Glad that worked for you!
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.
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.
Your post really solve my problem.. Thank you very much!Â
Thank you. Â You made this so easy!
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.