How to Move WordPress From Root Directory to Subdirectory?

Sometimes you wish to install WordPress in root (wwwroot/public_html) directory, but you do want to filled up the root directory with WordPress files and folders. In this situation, you can give WordPress website it’s own directory so that WordPress will be installed in subdirectory, but your website will be served from the root folder.

In more simple words, install WordPress in example.com/mywebsite directory and still you can access your website with URL http://mywebsite.com. Let’s see how we can achieve this.

  1. First create folder where you want to install WordPress. In this tutorial, we will use /mywebsite.

  2. Now, at WordPress dashboard, navigate to Settings >> General Settings.

    General Settings


  3. In the box WordPress address (URL), change the address to new location of your main WordPress core files. For example: http://example.com/mywebsite.

  4. In the box Site address (URL), change the address to the root directory URL. For example: http://example.com and click on Save Changes.

  5. Move your WordPress core files to the new location (/mywebsite folder).

  6. Now COPY (DO NOT MOVE) index.php and .htaccess files from /mywebsite folder to root directory, i.e. wwwroot/public_html.

  7. By default, .htaccess file would be invisible. Hence, set FTP client to show hidden files. If you are using cPanel file manager, check the show hidden files checkbox while you access file manager. Additionally, if you do not use pretty permalinks, then you may not have a .htaccess file.

    cPanel File Manager

    If you are running WordPress on a Windows (IIS) server, you will have web.config rather than .htaccess file. For index.php file, instructions remain the same, COPY (DO NOT MOVE) the index.php file to your root directory. For web.config file, MOVE (DON'T COPY -- exact reverse to .htaccess) it to your root directory.

  8. Now, open root directory's index.php file in a text editor. Replace line

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

    with following line, placing your subdirectory name as follows.

    require( dirname( __FILE__ ) . '/mywebsite/wp-blog-header.php' );
  9. Browse and login to new WordPress dashboard. http://example.com/mywebsite/wp-admin/

  10. If you have set up Permalinks, update the Permalink structure. At WordPress dashboard, navigate to Settings >> Permalinks Settingscheck the checkbox of permalinks setting you set previously and save the changes.


  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Migrate / Transfer WordPress Website from WordPress.com to AccuWeb Hosting?

To transfer your WordPress.com website to a self-hosted WordPress website, first you will need a...

How to Configure Your Settings in WordPress Blog?

How to configure your settings in WordPress This tutorial assumes you've already logged in to...

How to write a comment in WordPress

How to write a comment in WordPress This tutorial assumes you've already logged in to...

How to Deactivate All Plugins Without Accessing WP-Admin?

While troubleshooting any WordPress issues, you are asked to deactivate all plugins and activate...

How To Secure WordPress ADMIN Area?

There have now been several large scale WordPress wp-login.php brute force attacks, coming from a...