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

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

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

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

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

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

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

Before attempting to move WordPress

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

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

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

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

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

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

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

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

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

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

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

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

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


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

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

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

Remember that your login and registration links will still be

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

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


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

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

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

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


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


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

Angela Bowman

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

View all posts by Angela Bowman

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

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



    • 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

      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.


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


          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.

  2. 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 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’):

          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 “” 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:


            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?

  3. I want the site url to go to the wordpress folder
    I get when I try to login and when I type in 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

  4. 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” ( – 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 (

    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


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


      • 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


  5. Dear Angela,

    I have followed your tutorial to the core and am still unable to point my website “” to “”. 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

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


  6. 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 pointing to my subdirectory1 at my hosting. This is my my domain that I want to keep up.
    I have my 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

    What I tried…
    I changed the wp url and site url from the wp subdirectory2 to point to the
    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 instead of 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:


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

    My question is if there is a recommended method (if any), to remove it for the admin pages as well (e.g or instead of

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


      • 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

  8. 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:

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

    Pls help, i’m already behind the schedule 🙁 🙁


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


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


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

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


  10. 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!


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


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


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


          • Here’s another thing you might need to do: check your file permissions throughout the site to make sure all the file permissions are set correctly. I have had weird issues on some web hosts where files uploaded via FTP don’t get correct permissions and then weird behavior ensues.

            You can use this plugin:


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

          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:

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


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


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

  11. Hi, greate article.
    Just one problem: following this guide my website “front-end” now points to the “root” (like “”), which is fine. But the back-end still has an URL like “…”.
    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 and use it to rewrite all the old URLs for all the uploaded files to use the new root URL.

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

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

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


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

  15. 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!

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


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

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


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


  18. 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!

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

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

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

  21. Dear all,

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

    If I go to the site loads:

    Settings in the SQL database are:

    Dashboard general settings:

    When I go to get this error:

    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 🙁

  22. Hello Angela,

    My WP installation is still located in a /blog/ 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!

    • Hi Hazlo,

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

      What it does is automatically create a URL for each language. I am using it at 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.


      • Thanks Angela for your quick reply!
        So then it is MultiLingual Plugin vs Multisite installation.
        I looked at 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.

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

          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.

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

      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’ );


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



            instead of


            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.

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

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

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

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


    but the preview appears to be viewed at


    (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 -> /home/username//websites/old/working-copy-of-the-old-website

    I have also mapped -> /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. -> /home/username/websites/my-wordpress-directory

    Once I am ready to go public, I will re-map as follows -> /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

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

  27. Thank you so much for this. Worked like a charm, even though I was extremely worried about the process!

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

  28. 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. 🙂

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

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

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

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

    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

    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 🙂

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

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

    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 ?

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

      Once you do the process I describe, you will no longer see the posts at – 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 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 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!

Leave a Reply

Your email address will not be published. Required fields are marked *