Do you want to install WordPress in a subdirectory? Installing WordPress in a subdirectory allows you to run multiple WordPress instances under the same domain or even a subdomain name. Be it you want to run a separate WordPress install from your main one or make a testing environment, WordPress makes the task very easy. This can all be accomplished without affecting the actual domain you are creating the subdirectory in. 

To create those additional sites, subdomains or subdirectories should be used. However, before we go further in explaining how to Install WordPress i Subdirectory, there is the need to perfectly understand what subdirectories are.

What is a Subdirectory

A subdirectory is simply another name for a nested folder. That is, a folder located directly within a folder, as well as a folder that is stored in other folders within a folder. Although, Subdirectory work similarly like a subdomain, it is important to understand that these two terms different.

A subdomain compartmentalizes your website so you can establish specific content types that are distinct from your root domain, while a subdirectory is a pathway within your site. In other words, Subdomains appear before the domain name in a URL, such as blog.kara.com.ng, instead of a subdirectory, which would look like this: kara.com.ng/blog.

However, they both have their own set of benefits from creating a new website, like SEO. A subdirectory will benefit from the domain name and will rank higher than normal. So, let’s see how to install WordPress in a subdirectory without affecting the parent domain name.

How to Install WordPress in a Subdirectory

There are different ways to install a wordPress in a Subdirectory, however, for every process, you must first download the most recent copy of WordPress and install it in a subfolder of your choice on your web server. There are no additional plugins needed, but you will also need access to your websites cPanel, which is provided by your web host. Since you will be creating a subdirectory in an existing domain name that is in use.

Step 1. Create a Subdirectory under The Root Domain Name

First, you need to create a subdirectory or a folder under the main website. This is where you will install WordPress files. Then go to your cPanel provided by your web host. Click on the File Manager option or Connect to your WordPress hosting account using a FTP client to copy the index.php and .htaccess files then paste them into the domain root.

It is important to note that your WordPress files should be located in the public_html directory. You will want to create a new subdirectory in this section. Add a new directory by creating a new folder. Make sure you do not name the folder something that is already in use so it will be easy for you to identify the file.

Next, you need to right click and select ‘Create new directory’ from the menu.

Install WordPress in a Subdirectory.

Please note that the folder name is what your visitors will type into the URL to find it, so make sure it is appropriately named. It is also advisable to not leave a space in any of your files names, instead any needed space should be filled with a hyphen.

Step 2. Upload WordPress Files

Since it is a newly created subdirectory, it is obviously empty, so, you can now upload WordPress files in the folder. To do this, you need to visit WordPress.org website and click on the download button. The button will lead to a download of the zip file containing the latest “ WordPress 4.8.3” software to your computer.

After downloading the file, you need to select and extract the zipped folder into your newly created subdirectory folder by clicking on the extract button. Once it is done, you should see a WordPress folder containing all the WordPress files. Then upload these files to your new subdirectory by connecting to your website using an FTP client and go to the subdirectory you created in the first step.

In the local files panel of your FTP client, go to the ‘wordpress’ folder you just extracted. Select all files inside the folder and then upload them to your new subdirectory. Click on the move button and move all of the files directly into the New-Directory folder, then, delete the WordPress folder.

Step 3. Create New Database

WordPress stores all your content in a database, hence, there is the need to create a new database to use with your new WordPress site installed in a subdirectory.

Firstly, login to the cPanel dashboard of your WordPress hosting account and click on the MySQL Databases option. On this page, create a new database, username, password, and add the necessary information needed, then click on the ‘Create Database’ button to continue.

Step 4. Install WordPress

Once your dashboard is created and other necessary information has been put in place, you can now install WordPress by visiting the directory created earlier in a web browser by typing the URL in other to access the WordPress installation wizard. To install WordPress, you need to insert appropriate pieces of information which include your WordPress language, database name, database username, password, and host. After providing this information you can now install WordPress.

Step 5. Fix Permalinks

During the process of installing WordPress in a subdirectory, if you encounter 404 errors, note that this is as a result of an already installed WordPress in the root directory. But, this error can be easily fixed. To solve this, you need to edit the .htaccess file in your subdirectory WordPress install. Replace the code inside your .htaccess file with the following code:

  • # BEGIN WordPress
  • <IfModule mod_rewrite.c>
  • RewriteEngine On
  • RewriteBase /your-subdirectory/
  • RewriteRule ^index.php$ - [L]
  • RewriteCond %{REQUEST_FILENAME} !-f
  • RewriteCond %{REQUEST_FILENAME} !-d
  • RewriteRule . /your-subdirectory/index.php [L]
  • </IfModule># ENDWordPress

Read Also

LEAVE A REPLY

Please enter your comment!
Please enter your name here