How To Install WordPress in a Subdirectory

Many people ask me whether they should install WordPress in  a root directory or in a subdirectory.  You can do it either way.  If your website is built solely by WordPress and you are not very technical, it is better to install it in your root directory.  This is also the most popular way to install WordPress. 

However, the techie guys may not like it.  Their argument is that it is not secure and not organized.  They have a good point.  So let’s see how to install WordPress in a subdirectory.

Installing WordPress in a subdirectory but having your domain name point to it as if it was installed in the root directory can be a little tricky.  Though has an article explaining how to do it, it is hard for beginners to follow.  In this blog, I’ll do my best to make it as easy as possible for you to work with.

  • Step 1: Install WordPress in a subdirectory.  For example,
  • Step 2: Log in to your WordPress back office, go to Settings -> General.
    1. In the box for Site address (URL): change the address to the root directory’s URL. Example:   *** Not WordPress URL***
    2. Click Save Changes. (Do not worry about the error message and do not try to see your blog at this point! You will probably get a message about file not found.)

    install WordPress in a subdirectory

  • Step 3: Log in to your Hostgator cPanel, go to the “File Manager.”  You need to access the root directory of the domain you are working on.  As the .htaccess file is invisible, select the checkbox to show hidden files.


  • Step 4: Open the subdirectory where WordPress is installed.  In my example, it is the “blog” folder.  Copy (NOT MOVE!) the index.php and .htaccess files from the subdirectory into the root directory of your site.
  • Step 5: Edit your root directory’s index.php.
    1. Open your root directory’s index.php file in Code Editor.
    2. edit-fileChange the line that says:   require('./wp-blog-header.php');
      to the following using your subdirectory name where WordPress is installed.  If your subdirectory is “wordpress”,  then you should change this line of code to:
    3. Save the file.
  • Log in to your site, the URL should still be

I find this video tutorial very helpful.  Hope you know how to install WordPress in a subdirectory.  I will let you decide whether you want to install WordPress in a subdirectory or root directory :)

The following two tabs change content below.
Mary Wang: Founder of Golden Vision Training and the creator of WELCOME Lead Generation System. Since 2010, Mary has helped 5000+ entrepreneurs and small business owners build their online business, generate more leads, double their sales and income online. Learn more about Mary's home study course - Double Your Income Online Blueprint.