How to Install WordPress in a Subdirectory (Step by Step)

images-wordpress

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. In this article, we will show you how to install WordPress in a subdirectory without affecting the parent domain name.

Installing WordPress in a subdirectory

Subdomain vs Subdirectory? Which One is Better for SEO?

Normally, you would want to start a WordPress website on its own domain name (for example, wpbeginner.com). However, sometimes you may want to create additional websites on the same domain name.

This can be done by either installing WordPress in a subdomain (https://ift.tt/2hzonaq) or as a subdirectory (https://ift.tt/2xFg3Kh).

One question that we get asked is which one is better for SEO?

Search engines treat subdomains differently from root domain names and assign them rankings as a separate website.

For instance, search Engines consider WPBeginner and our WPBeginner Videos website as two separate websites.

On the other hand, sub-directories directly benefit from the domain authority of the root domain thus ranking higher in most cases.

One way to create separate WordPress sites in both subdomain or subdirectory is by installing WordPress multisite network.

However, if you want to keep two websites managed separately, then you can install different instances of WordPress. You can also use WordPress site management tools to set up a single dashboard for managing your multiple WordPress installations.

Requirements for Installing WordPress in Subdirectory

There are no special requirements to install WordPress in a subdirectory. If you already have a WordPress website in the root domain name, then you are good to go.

All top WordPress hosting companies make it very easy to install multiple WordPress websites using the same hosting account.

For instance, if you are using Bluehost, you can add a new WordPress website from your hosting dashboard.

Adding new websites in Bluehost

However, please keep in mind that most shared hosting accounts have limited server resources. A sudden traffic spike on one of your websites will affect the performance and speed of all other websites on the same account.

If you are just starting out, then you can do that on shared hosting. Keeping in mind that you’ll need to upgrade to a managed WordPress hosting as your business grows.

That being said, let’s take a look at how to easily install WordPress in a subdirectory.

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.

Connect to your WordPress hosting account using a FTP client or File Manager in cPanel.

Once connected, go to the root folder of your website. Usually it is the /public_html/ folder. If you already have WordPress installed in the root folder, then you will see your WordPress files and folders there.

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

Create subdirectory

You need to be careful when choosing the name for your subdirectory. This will be part of your new WordPress site’s URL and what your users will type in their browsers to reach this website.

For example, if you name this directory travel-guides then your WordPress website’s address will be:

https://ift.tt/2hzlZ3j

New subdirectory created

Step 2. Upload WordPress Files

Your newly created subdirectory is empty at the moment. Let’s change that by uploading WordPress files.

First you need to visit WordPress.org website and click on the download button.

Download WordPress
Your browser will now download the zip file containing the latest WordPress software to your computer.

After downloading the file, you need to select and extract it. Mac users can double click the file to extract it and Windows users need to right-click and then select ‘Extract All’.

After extracting the zip file, you will see ‘wordpress’ folder containing all the WordPress files.

Now let’s upload these files to your new subdirectory.

Connect 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.

Upload WordPress files to the subdirectory

Step 3. Create New Database

WordPress stores all your content in a database. You need to create a new database to use with your new WordPress site installed in a subdirectory.

First, you need to login to the cPanel dashboard of your WordPress hosting account. Click on ‘MySQL Databases’ under the databases section.

Creating a MySQL database

Note: Your hosting dashboard may look different than the screenshot above. You simply need to locate the ‘Databases’ section.

On the next screen, enter a name for your new database and then click on the ‘Create Database’ button to continue.

Create a new database

Your cPanel dashboard will now create the new MySQL database. Click on the Go Back button to return to the Databases page.

Next, you need to add a username and password for the database.

Simply scroll down to the ‘MySQL Users’ section and provide a new username and password. Click on ‘Create User’ button to continue.

Create database user and password

Next, you need to give this newly created user privileges to work on the database you created earlier.

Scroll down to ‘Add user to database’ section. Select your MySQL username and then select your newly created database.

Add user to database

Click on the Add button to continue.

Cpanel will now grant the MySQL user full privileges on your newly created database.

Step 4. Install WordPress

Now that everything is in place, you can go ahead and install WordPress. Simply visit the directory you created earlier in a web browser by typing the URL like this:

https://ift.tt/2xF4suA

This will bring up the WordPress installation wizard. First, you need to select the language for your WordPress website and click on the continue button.

Select language

Next, you will be asked to provide your WordPress database name, database username, password, and host. Enter the database details and click on the submit button.

Provide your database details

WordPress will now connect to your database and you will see a success message like this:

WordPress database connected

Click on ‘Run the install’ button to continue.

On the next screen, you will be asked to provide a title for your website and choose an admin username, password, and email address.

WordPress website details

After entering your website details, click on ‘Run install’ button to continue.

WordPress will now set up your website and will show you a success message:

WordPress successfully installed in the subdirectory

You can now go ahead and login to your new WordPress website installed in the subdirectory.

Step 5. Fix Permalinks

If you have a separate WordPress install in the root directory, then the .htaccess files of your subdirectory will cause conflict. This will result in 404 errors on your website.

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>

# END WordPress

Don’t forget to replace /your-subdirectory/ with your own subdirectory name.

We hope this article helped you install WordPress in a subdirectory. You may also want to see our ultimate step by step WordPress SEO guide for beginners.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

The post How to Install WordPress in a Subdirectory (Step by Step) appeared first on WPBeginner.

Share:

Post a Comment

Designed by OddThemes | Distributed by Blogger Themes