Steps about How to Install WordPress in a Subdirectory

Steps about How to Install WordPress in a Subdirectory

It is possible that you want to run multiple WordPress sites on a single hosting account. To achieve this, you can install the WordPress multisite network so as to manage them as a whole. However, if you want to have these sites controlled separately and keep the installs organized, you can install WordPress in a subdirectory with much ease. The following steps will tell you how to do this in different situations.

Before presenting the steps, we firstly want to demonstrate the differences between installing WordPress in a subdirectory and in a sub-domain. If you install in a subdirectory, the website URL looks like “”. However, if you install in a sub-domain, it looks like “”. It is true that both of these two options allow you to start multiple websites. But from the SEO point of view, the former one is the better option. After all, search engine spiders will regard the subdomains as the new sites and rank them differently from your main domain. The subdirectories, however, can benefit from the main domain authority so as to be ranked higher.

Install WordPress in a Subdirectory from Scratch

If you haven’t installed any WordPress instance on your hosting account, the installation of WordPress in a subdirectory is really easy. Here, you just need to enter your control panel to target the 1-click WordPress installer. Note that this is the common tool offered by almost all the quality web hosting providers.

After finding the target, you should choose the WordPress icon to start installing, and then, fill out the below fields.

  • Enter and choose the domain name you want to use for this install.
  • Determine the subdirectory you are looking to install WordPress into. Note that the folder cannot exist by default on your server. Thus, you should type the subdirectory name manually.
  • Enter the username, password and email address of your admin.

Now, you should click the Install button and the rest can be done automatically in a short time.

Finish Some Settings

Upon the installation, you also should set up WordPress after entering the dashboard. Here, you firstly need to click the Settings > Permalinks button, and then, hit the Save Changes button. This can generate a .htaccess file, which is an essential directory-level file for URL shortening, URL redirection and some other website access issues. This step is important as WordPress sometimes does not generate or update this critical file automatically.

Permalinks Settings

Next, you should click the Settings > General button to set up the WordPress Address and Site Address options.

  • WordPress Address – The folder address where you install WordPress.
  • Site Address – The URL of your website.

Both of them should have “http://” or “https://”, without the final slash. If you install WordPress in the root directory, the value of these two fields should be the same. But now, you should remove the “/subdirectory” part from the Site Address field. Surely, if you will install another WordPress in the root directory and make this website a part of it in the future, you can pass this step.

Site Address Settings

Next, you can save the settings, but do not refresh your website. Instead, you should use your FTP client to connect to your site. And then, you can copy the generated .htaccess file and index.php file from your WordPress folder – the one you install WordPress. After that, you should enter the root directory and paste them together.

Here, do not forget to open your index.php file to replace

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


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

Install WordPress in a Subdirectory after the First Install

If you have already installed WordPress with the root domain on your hosting account, you should go through different steps.

Create New Directory

To begin with, you should go to the root folder of your website by using the FTP client or the File Manager in your control panel. Usually, it is on the /public_html/ folder. You just need to click it and generate the new directory by right clicking the Create Directory button.

Create Directory

Note that when creating the subdirectory, you should be careful of the directory name. After all, you will use it as the website URL later.

Upload WordPress Files

Now, your new subdirectory folder is empty. Thus, you need to put the WordPress files in. To achieve this, you can go to to download the latest version of WordPress. The downloading file is a ZIP one. In this case, you should right click the file and select the “Extract All” option.

Then, you can see the “wordpress” folder. And you just need to upload all the files within this folder to your subdirectory with your FTP client.

Create Database

The next step is to create the new database to store the content of your WordPress website. For this, you can create the database using phpMyAdmin.

Or, you can finish this using your cPanel. This way, you need to login to your control panel and click the MySQL database icon from the Database section.

In the next page, you need to enter the name of your new database and click the Create Database button.

Create Database

In addition, you also need to create a new MySQL username and give it the privileges to run this database. The creation requires you to enter the username and password only.

Create MySQL User

Lastly, you just need to scroll down to the “Add user to database” section. Here, you can choose your database and user from the dropdown menu, and then, click the Add button.

Run WordPress Installation

Now, everything is ready. So, you can run WordPress installation by typing “” in the address bar of your browser. This can bring you to the installation wizard of WordPress directly. Here, you firstly should choose the language to install.

Choose WordPress Language

Next, you should enter your database details, including the database name, username, password, host and table prefix. Note that “localhost” is the database host in general. If it does work, you should ask your web host. As for the table prefix, it is “wp_” by default. However, you have to distinguish the prefix of your subdirectory website from that of your main website. In this case, you’d better change the table prefix to something else.

Database Details

After connecting WordPress script with your database, you can click the Run the Install button. Here, do not forget to provide your subdirectory website information, including site title, username and password of your admin panel, your email and the search engine visibility.

A few seconds later, you can install WordPress in a subdirectory successfully.

Fix .htaccess Error

As you already install WordPress in the root directory, the .htaccess file of the new install can lead to conflict. This conflict issue can result in the 404 error on your site. In this case, you should edit the .htaccess of your subdirectory site and replace the code with the following lines.

Fix .htaccess Error