7 Easy Steps to Install WordPress in a Subdirectory

how to install wordpress in a subdirectory

Looking for a simple and easy-to-follow guide on how to install WordPress in a subdirectory? You’re in the right place. This is a clutter-free tutorial for you, devoid of any unnecessary steps.

There are many ways to install WordPress in a subdirectory. We recommend using the cPanel since it’s the most uncomplicated process.

Carefully follow the steps mentioned in this precise guide to install WordPress in your subdirectory successfully. Before diving deeper, let us show you what a subdirectory is and how it differs from a subdomain.

What Is a Subdirectory- Let’s Clear The Concept

A subdirectory is like a folder nested under the parent folder. Here, your domain is the parent directory, and any additional website created in the same domain is a subdirectory.

It usually functions as a subsection of the domain or a staging site for testing purposes.

Why would you need a subdirectory when you already have a website? We’ve answered that in a later part. Now let’s learn why we prefer creating a subdirectory rather than creating a subdomain.

Subdirectory vs. Subdomain- Are They Same? 

Subdirectory vs. Subdomain

Many people feel confused when choosing between a subdomain and a subdirectory. Both a subdirectory and a subdomain are subsections under a root directory. You will understand the difference simply by looking at the URL path.

A subdirectory shows a URL like yourdomain.com/subdirectory. And a subdomain’s URL looks like subdomain.yourdomain.com.

Subdomains work like separate websites, whereas subdirectories are considered a distinct segment of the main site.

Subdirectories are easy to optimize for search engines since they share the same domain authority as the parent websites. You should choose a subdirectory if you want to run a small website related to the niche of the main website.

On the other hand, subdomains are less SEO-friendly as you have to build the domain authority from scratch. They are preferable for bigger websites, usually unrelated to the main domain’s content.

The Bottom Line: Search engines consider subdomains as unique websites and rank their content based on the authority of the new domain, ignoring the root website. Evidently, subdirectories have the upper hand in the Subdirectory vs. Subdomain debate when it comes to SEO.

Why You May Want to Install WordPress in a Subdirectory

You have a fully-functional website up and running in full swing. Then what’s the necessity to create a subdirectory on WordPress? We’ve gathered the top reasons in this section to facilitate your decision.

  • Help Multilingual Audience: Suppose, you have a diveresed group of audience from different language backgrounds. You can create sundirectories written in a specific language for each of them.
  • Run Your eCommerce Securely: It’s wise to keep your eCommerce shop aside from other segments of the website. You can create a WordPress subdirectory and set up WooCommerce there to run your online store.
  • Use Multiple CMSs Within a Single Domain: Subdirectories come in handy when you need to use two or more content management systems within a single website. Suppose, your online store is based on Joomla but you want to keep the blog section on WordPress for its usability. You can simply install WordPress in a subdirectory and publish your blogs there.
  • Use The Subdirectory for Testing Purposes: You may have an amazing idea and need a staging site to conduct A/B testing. Subdirectories can be used as a testing ground without deteriorating the existing website’s health.

Now that you know why subdirectories are necessary, let’s explore how to install WordPress in a subdirectory in the most straightforward manner.

How to Install WordPress in a Subdirectory- 7 Easy Steps

Install WordPress in a subdirectorty

Since you’re here to learn how to install WordPress in a subdirectory, we assume you already have a website up and running with access to the cPanel. Log in to your cPanel using the credentials. Then follow the below steps cautiously to install WordPress in a subdirectory successfully at the first attempt.

1. Create a New Database

  • After logging in to the cPanel, you’ll see multiple options. Scroll down and find MySQL Databases and click on the link.
Choose MySQL Database
Choose MySQL Database
  • It will lead you to a new page with options to create a new database or modify any existing database. Give a name to your database. Here we named the database as ‘subdirectory’ to help you understand better. Hit the Create Database button.
Create a New Database
Create a New Database
  • A database will be added for you containing the username previously given by cPanel.
  • Here, the cPanel username is bestIgme, so the database is bestIgme_subdirectory. You’ll need this name in further steps, so take note of this name somewhere safe.
  • Now click the Go Back link.
Successful Database

2. Add a New User

  • Scroll down the page and find the Add New User section. Give a username and choose a strong password to create a new user. You can use the default Password Generator if you want.
Add a New User
Add a New User
  • Here, the username is wptutorialforyou. Now hit the Create User button, and a new username will be created for your database.
Successful Username
  • Note down the database username (bestIgme_wptutorialforyou) and password. Go back to the previous page to add this username to the newly created database.

3. Add User to the Database

  • Click on the dropdown menu to select both the new user and database for your system.
  • Hit the Add button, and your database and username will be synchronized for future steps.
Add User to Databse
Add User to Database
  • You’ll be directed to a page with the list of user privileges for the database. Put a tick on the checkbox stating ALL PRIVILEGES.
Manage User Privileges
Manage User Privileges
  • Then, hit the Make Changes button available at the bottom of this page. The database and user will get connected at this stage. You’ll see a success notification immediately.
  • Click on the Go Back link to complete other required steps.
Successful username and database

4. Create a New Folder Inside the File Manager

  • Select the File Manager option available on the cPanel homepage. You’ll be taken to the folder comprising all files of your database.
Choose File Manager
Choose File Manager
  • Click on public_html to enter the root folder of your website.
Public HTML
  • Choose the Folder option with the + icon.
Create a New Folder
Create a New Folder
  • Give a name to your folder. Be very careful when choosing this name. This is the URL that will appear just after your domain name. We chose subdirectory-test-url for this tutorial.
Name the Folder
Name the Folder
  • You’ll see a new folder inside the root public_html, as shown in the below picture.
Subdirectory URL

Interesting Fact: As we know the final URL of our Subdirectory now, let’s check if it’s available on the internet.

404 Error
  • You’ll be shown a 404 or 403 error at this stage. Finish the remaining steps to get a fully functional Subdirectory as intended.

5. Upload WordPress to the New Folder

If you don’t have the latest WordPress version downloaded on your computer, follow the next steps to download it.

  • Visit the wordpress.org website and click the Get WordPress button.
WordPress.Org
  • Download the latest version available on the website. Remember the folder name where you download files on your computer. You will be required to upload it to the cPanel in the next steps.
Download the Latest Version of WordPress
Download the Latest Version of WordPress
  • The new folder named subdirectory-test-url is empty now.
  • You need to upload the latest version of WordPress here to add the subdirectory to the WordPress ecosystem.
Upload WordPress ZIP
Upload the WordPress ZIP
  • Choose the Upload option, and you’ll be directed to an uploading page.
  • You can easily hit the Select File button and choose the WordPress ZIP files to start uploading.
how to install wordpress in a subdirectory
  • Select the previously downloaded ZIP file and wait for the system to complete the upload process.
how to install wordpress in a subdirectory
  • Wait until the uploading progress bar reaches 100% and the color turns green.
  • Then click the Go Back link to our target folder subdirectory-test-url.
Wait for the Green Color
Wait for the Green Color

6. Extract the WordPress Files

  • If everything goes right, you’ll get the WordPress ZIP file ready at your disposal inside the new folder. Select the ZIP file and click on Extract to unzip the compressed files.
Extract the Zipped Files
Extract the Zipped Files
  • A small wizard will pop out. Hit the Extract File(s) button to complete the extraction process.
Extract Files
  • This wizard will show you the extraction results as displayed in the picture. Click on the Close button to finish the process.
Close Extraction Results
Close Extraction Results
  • The chances are high that you’ll see a new folder named wordpress available inside the target subdirectory folder.
  • If you don’t find it automatically, click Reload to refresh the folder items.
how to install wordpress in a subdirectory
  • Now click on the wordpress folder to explore the unzipped files.
  • Tick the Select All checkbox and Move all files to the root folder of your subdirectory.
how to install wordpress in a subdirectory
  • Delete the wordpress portion from the file path before moving.
  • After omitting wordpress, the file path will be like public_html/subdirectory-test-url for the subdirectory we’re creating throughout this article.
  • Then, click Move File(s) to finish the process.
Move Files to the Root Subdirectory Folder
Move Files to the Root Subdirectory Folder
  • You’ll see two folders named wordpress and wordpress-version.zip (In this case, the version is 5.8.3) once you cut the items to the desired folder.
  • We don’t need these two folders anymore. So mark them and Delete them.
how to install wordpress in a subdirectory

Add Database Info in the WP-Config Codes

  • Scroll down and right click on the wp-config-sample.php, choose the Edit option. It will lead you to the codebase of this file.
Edit the WP Config File
Edit the WP Config File
  • Hope, you saved the database name, username, and password in a safe place as we did.
  • Now, replace the default DB_NAME, DB_USER, DB_PASSWORD fields as provided by WordPress with your credentials.
  • We used our credentials here as shown in the picture.
Rewrite the Database Name, User, Password
Rewrite the Database Name, User, Password
  • You’re almost done with the background work. Rename the wp-config-sample.php file omitting -sample portion. The final config file is wp-config.php.
wp-config

Only one step is remaining. Now you can finally install WordPress in your subdirectory without any error.

7. Install WordPress in the Subdirectory

It’s time to leave the cPanel since your work with the database is complete.

  • Go to a new tab on your browser and type the URL of your subdirectory, and press enter. In our case, the URL pattern is example.com/subdirectory-test-url.

Good luck! If each of the above steps is right on point, you’ll see the WordPress installation page.

  • Choose your preferred language and hit the Continue button.
Choose a Language
Choose a Language
  • Give a suitable Site Title, Username, and a strong Password to your WordPress subdirectory.
  • Don’t forget to add a valid email to Your Email field. You can discourage search engines from indexing your subdirectory by checking the Search engine visibility option.
  • Hit the Install WordPress button to reach the second phase of the installation process.
Install WordPress
Install WordPress

WordPress will welcome you with a Success message.

how to install wordpress in a subdirectory
  • Now log in to your dashboard by providing the username and password. We used your-username for this tutorial.
Log in to WordPress
Log in WordPress
how to install wordpress in a subdirectory
  • Let’s check how this subdirectory appears before the internet users. Type the correct URL on the browser and press enter. You’ll see the front end in a default WordPress theme.
how to install wordpress in a subdirectory

All done!

You came this far? Indeed, you deserve a pat on the back for your patience and effort. Your subdirectory based on WordPress is ready. Now you can use this WordPress subdirectory as a website.

Install necessary plugins and ensure optimal security for a hassle-free WordPress experience.

Bonus Tip – Fix Permalinks (if necessary)

We hope you don’t need this bonus tip. Your subdirectory should be up and running smoothly if created as per our instructions.

Some people may face 404 errors even after doing everything right if they have a separate WordPress installed in the root directory. In case you encounter this issue, we have given the solution beforehand. Fix the permalink issues with simple steps as follows.

1. Open the .htaccess file of your subdirectory

2. Copy 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>
# END WordPress

3. Replace the code available inside your .htaccess file with the copied code from the above step

4. Rename your-subdirectory field with the name of the subdirectory you’re trying to create

5. Save the changed code, and you’re ready to roll.

Choose the Right Plugins for Your WordPress

The default WordPress features are enough for beginners. You need to use plugins, extensions, and themes to level up your WordPress game. There are thousands of plugins available on WordPress.org.

Choosing the best fit for your needs is a real challenge. WP Hive has made it easier for all WordPress users.

Its Plugin Testing tool automatically examines a plugin, analyzes its pros and cons, and provides you with better insights. You can also try testing any plugin using WP Hives’s Chrome extension.

Subscribe to our blogs, follow our Facebook and Twitter handles for more WordPress tutorials, news, articles, deals, reviews, and more.

Liquid Web
Wordpress Icon

Disclosure: WP Hive earns a commission when you buy through partner links. It does not influence the unbiased opinions of our writers. Learn more →

Share:

https://wphive.com/tutorials/how-to-install-wordpress-in-a-subdirectory/Copy icon

Tanvir Faisal

Md. Tanvir Faisal is a Content Writer at WP Hive with over 7 years of experience in Content Writing, Copywriting, Proofreading, and Editing. He specializes in creating helpful content that engages readers, drives social media shares, and improves SEO ranking. In his free time, Tanvir enjoys exploring new cuisines, traveling to unknown places, and spending quality time with his family.

Subscribe To Our Newsletter

Newsletter Subscription Form

Leave a Reply

Your email address will not be published. Required fields are marked *