Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

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

Installing WordPress in a subdirectory can be very useful. It lets you run multiple WordPress sites under the same domain.

This setup is great for organizing content. It also helps manage different projects without affecting the main site.

In this guide, we’ll show you how to install WordPress in a subdirectory. The process is straightforward and won’t impact your parent domain.

By the end, you’ll have a new WordPress site up and running in a subdirectory.

Installing WordPress in a subdirectory or folder

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 using the same domain name.

This can be done by either installing WordPress in a subdomain (http://newebsite.example.com) or as a subdirectory (http://example.com/newwebsite/).

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

Search engines treat subdomains differently from root domain names and assign rankings as separate websites.

For instance, search engines consider WPBeginner and our WPBeginner Videos sites to be 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 subdomains or subdirectories is by installing a WordPress multisite network.

However, if you want to keep two websites managed separately, you can install different instances of WordPress.

You can also use WordPress site management tools to set up a single dashboard for managing multiple WordPress installations.

Requirements for Installing WordPress in Subdirectory

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

However, if you have a static (non-WordPress) website, you may need to check with your hosting company to see if they support WordPress.

If they don’t, then you’ll need to move your website to a different hosting company.

We recommend using Bluehost. They are offering a generous discount on hosting to WPBeginner users with a free domain name.

If you are using a different hosting provider, then 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, then you can add a new WordPress website from your hosting dashboard.

Bluehost add new site

However, please remember 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. Remember that you’ll need to upgrade to managed WordPress hosting as your business grows.

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

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 an FTP client or File Manager in cPanel.

Once connected, go to your website’s root folder, which is usually the /public_html/ folder.

You will see your WordPress files and folders if you already have WordPress installed in the root folder.

Next, right-click and select ‘Create new directory’ from the menu.

Create new directory

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:

http://example.com/travel-guides/

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 the 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 the ‘Extract All’ option.

Extract WordPress

After extracting the zip file, you will see a ‘wordpress’ folder.

Inside the wordpress folder, you’ll see all the core WordPress files and folders.

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

Step 3: Create a New Database

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

First, log in to the dashboard of your WordPress hosting account and click on the ‘Settings’ button below your website.

Bluehost site settings

After that, switch to the ‘Advanced’ tab from the top menu.

Scroll down a little to the cPanel section and then click ‘Manage’.

Launch cPanel dashboard in Bluehost

This will launch the cPanel or the advanced hosting control panel.

From there, you need to click on ‘MySQL Databases’ under the Databases section.

cPanel 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 your new database’s name and click on the ‘Create Database’ button to continue.

Create new MySQL 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 the ‘Create User’ button to continue.

Adding new MySQL user

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

Scroll down to the ‘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.

Visit the directory you created earlier in a web browser by typing the URL like this:

http://example.com/your-subdirectory-name/

This will bring up the WordPress installation wizard. First, select the language for your WordPress website and click on the ‘Continue’ button.

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

WordPress database details

WordPress will now connect to your database.

After a connection is made, you will see a success message like this:

Database connected

Click on the ‘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.

Enter website details

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

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

WordPress install finished

You can now log in to your new WordPress website, which is 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 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.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us. Here's our editorial process.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

The Ultimate WordPress Toolkit

Get FREE access to our toolkit - a collection of WordPress related products and resources that every professional should have!

Reader Interactions

90 CommentsLeave a Reply

  1. Olaf

    A subdomain or subfolder can be a great choice if you need a new WordPress instance, for example, for a separate online store or discussion forum. You don’t even need a new database. Everything can be handled with a single database if you choose a different prefix during installation. From my own experience, though, .htaccess can sometimes cause issues. In your article, I see for the first time that someone took the time to adjust the code and added the RewriteBase line to make sure everything works as it should. I admire how thoroughly you’ve crafted your tutorials.

Leave A Reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.