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 WordPress.org 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, http://www.yourdomain.com/wordpress
  • 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: http://yourdomain.com   *** 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.

    root-directory

  • 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:
      require('./wordpress/wp-blog-header.php');
    3. Save the file.
  • Log in to your site, the URL should still be http://yourdomain.com/wordpress/wp-admin/

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

Golden Vision Training
1140 Burnhamthorpe Rd West, Unit 129B MississaugaONL5C 4E6 CA 
 • 905 361 8881
The following two tabs change content below.
Mary Wang: Founder of Golden Vision Training and the creator of Double Your Income Online Blueprint. Mary has helped entrepreneurs, small business owners and people who want to achieve financial freedom to double their sales and income online since 2010. She is passionate about financial education and personal development.

Latest posts by Mary Wang (see all)