How to Install WordPress in a Separate Directory

install wordpress own directoryA WordPress installation contains a lot of files and can clutter up your website’s root directory. This is especially painful if you are using shared hosting and you would like to keep the root directory of your primary domain clean. This guide shows you how to install WordPress in a separate directory instead of installing in the root directory.

  1. Install WordPress in a separate folder. i.e. If your website root is then install WordPress in Your website (WordPress installation) can now be accessed at
  2. Log in to your WordPress install
  3. Go to the General panel.
  4. In the box for Site address (URL): change the address to the root directory’s URL. Example:
  5. Click Save Changes. At this point, your website will not be accessible.
  6. Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress ( in our example) directory into the root directory of your siteā€”the latter is probably named something like www or public_html.
  7. If you have an old site or have configured permalinks in this WordPress installation then again Copy (NOT MOVE!) the .htaccess file from the WordPress directory into the root directory of your site. The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are running WordPress on a Windows (IIS) server and are using pretty permalinks, you’ll have a web.config rather than a .htaccess file in your WordPress directory.
  8. Edit your root directory’s index.php. Open your root directory’s index.php file in a text editor and change the line that says:
    require( dirname( __FILE__ ) . '/wp-blog-header.php' );

    to the following, using your directory name for the WordPress core files:

    require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
  9. Save the file.
  10. Login to your site (if you aren’t still already). The URL should still be
  11. If you have set up Permalinks, go to the Permalinks panel and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can’t write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)

Note: Since the site will be down during some of these steps, it is best to make this change at a time of low activity, e.g., the middle of the night.


You might also want to read up on How to Redirect 404 pages in WordPress and How to add a Back Button in your WordPress page.

Comment Policy: Comments adding value to the article are encouraged. Relevant links will be allowed in such comments.
If you think that you have a link that adds value to this article please contact us at techie[at]techzog[dot]com for evaluation of inclusion into the article.
Comments left solely for spamming links will be deleted. Thank you for understanding.

Leave a Reply

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

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.