How to Install WordPress in a Subdirectory (Complete Step-by-Step Guide)
Running multiple websites under a single domain is more common than most people realise.
Maybe you want a separate blog, a WooCommerce shop, a booking portal, or a staging area —
all living inside your main domain rather than on a completely different hosting account.
Installing WordPress in a subdirectory is the cleanest way to do exactly that.
In this guide I will walk you through every step in plain language, from creating the folder
on your server right through to verifying that your new site loads correctly.
If you are not sure whether WordPress is the right platform for your project in the first place,
have a read of my article on
WordPress vs Custom Website Development before you start.
What Does “Installing WordPress in a Subdirectory” Actually Mean?
When you install WordPress in a subdirectory, you are placing a completely independent
WordPress installation inside a folder on your existing hosting account.
For example, if your main site is at
yourdomain.com, your new WordPress install
would live at something like
yourdomain.com/shop,
yourdomain.com/blog,
or
yourdomain.com/booking. This is different from a WordPress
subdomain (
shop.yourdomain.com).
A subdirectory install uses a folder path, not a separate DNS record.
Both the main site and the subdirectory site share the same hosting account, but each has its
own WordPress database, its own set of plugins and themes, and its own admin dashboard.
They do
not interfere with each other.
From an SEO perspective, a subdirectory is generally considered stronger than a subdomain because search engines treat the content as part of the main domain’s authority.
If you are serious about search visibility, this matters.
You can learn more about how I approach
SEO for WordPress websites on my services page.
Before You Begin: What You Will Need
- Access to your web hosting control panel (most hosts use cPanel)
- FTP client software such as FileZilla, or your host’s built-in File Manager
- The latest WordPress package, downloaded free from wordpress.org
- A text editor (Notepad++, VS Code, or even plain Notepad will do)
- Around 20 to 30 minutes of uninterrupted time
Make sure your hosting plan supports multiple databases. On shared hosting this is almost always the case, but it is worth confirming before you start.
If you are looking for reliable hosting for your WordPress sites,
take a look at the hosting plans I offer .
Step 1 — Create the Subdirectory on Your Server
Log in to your hosting control panel and open the
File Manager.
Navigate to the
public_html folder — this is the web root of your main domain.
Create a new folder here and give it a short, lowercase, hyphenated name that reflects the
purpose of the new site. For example:
public_html/shop — for a WooCommerce storepublic_html/blog — for a separate editorial blogpublic_html/booking — for a reservation system
Avoid spaces and uppercase letters in folder names.
The folder name becomes part of the URL, so keep it clean and readable.
Tip: If you are using an addon domain or a subdomain as your main site,
the web root might be a different folder. Check your hosting panel’s domain settings to
confirm which folder corresponds to the site you want to extend.
Step 2 — Create a New MySQL Database and User
Every WordPress installation needs its own database.
In cPanel, scroll down to the
Databases section and click
MySQL Databases.
- Create a new database. Give it a descriptive name, for example
yourusername_shop.
Write this name down — you will need it shortly. - Create a new database user. Scroll down to the MySQL Users section.
Enter a username and a strong password. Write both down carefully.
- Add the user to the database. Scroll to Add User to Database.
Select the user and database you just created, then click Add.
On the next screen, grant ALL PRIVILEGES and confirm.
At this point you have an empty database, a dedicated user with full access to it, and a subdirectory waiting on your server. Now it is time to add the WordPress files.
Step 3 — Download and Upload WordPress
Go to
wordpress.org/download and download the latest stable release as a
.zip file.
Extract the zip on your local computer. You will see a folder called
wordpress containing all the core files.
Important: You want to upload the
contents of the
wordpress folder into your subdirectory — not the folder itself.
So the result should be:
public_html/shop/wp-admin/
public_html/shop/wp-content/
public_html/shop/wp-includes/
public_html/shop/index.php
public_html/shop/wp-config-sample.php
... and so on
You can do this via your host’s File Manager (upload the zip and extract it there, then move
the files up one level) or via FTP with FileZilla (connect to your server, navigate to the subdirectory, and drag the files across). The FTP method is often faster for large uploads because File Manager can time out on a slow
connection. Either way, wait for the transfer to complete fully before moving on.
Step 4 — Configure wp-config.php
Inside your subdirectory you will find a file called
wp-config-sample.php.
Rename it to
wp-config.php — you can do this directly in File Manager by right-clicking the file and choosing Rename. Open the file for editing and find the following section:
define( 'DB_NAME', 'database_name_here' );
define( 'DB_USER', 'username_here' );
define( 'DB_PASSWORD', 'password_here' );
define( 'DB_HOST', 'localhost' );
Replace the placeholder values with the database name, username, and password you created in Step 2.
The
DB_HOST value is almost always
localhost on shared hosting.
If your host is different they will tell you what to use. Next, scroll down to the
Authentication Keys and Salts section.
Visit
api.wordpress.org/secret-key/1.1/salt/ to generate a fresh set of keys and replace the placeholder lines entirely.
This is an important security step that many guides skip. Save the file. That is your wp-config.php done.
Step 5 — Run the WordPress Installation Wizard
Open a browser and go to
yourdomain.com/subdirectory/ — for example
yourdomain.com/shop/. WordPress will detect that it has not been installed yet and launch the installation wizard.
Work through the screens:
- Choose your language — select your preferred language and click Continue.
- Site information — enter:
- Site Title: the name of this new WordPress site
- Username: your admin username (do not use “admin” — it is a security risk)
- Password: use a strong, unique password
- Your Email: your admin email address
- Search Engine Visibility: leave unchecked unless you want to block indexing during development
- Click Install WordPress.
The installer runs for a few seconds and then shows you a success screen with a Log In button.
Click it and log in with your new credentials.
You are now inside the dashboard of your brand new WordPress site. If you see a database connection error instead of the wizard, go back to Step 4 and double-check
that your database credentials in
wp-config.php are exactly correct, with no extra
spaces or typos.
Step 6 — Verify Your WordPress Address and Site Address Settings
Once inside the new dashboard, go to
Settings > General.
You will see two fields:
- WordPress Address (URL) — where your WordPress core files are located
- Site Address (URL) — the public URL visitors use to reach the site
Both of these should already show the full subdirectory URL, for example
https://yourdomain.com/shop.
If they do, you do not need to change anything. If either one shows only your root domain without the subdirectory path, correct it now.
Entering the wrong URL here can lock you out of the dashboard, so be careful.
Save the changes. Now go to
Settings > Permalinks.
Select your preferred URL structure — the
Post name option
(
/sample-post/) is the most SEO-friendly choice for most sites.
Click
Save Changes.
WordPress will write the necessary rewrite rules into a
.htaccess file automatically. Good permalink structure is one of the basic building blocks of on-page SEO.
If you want to understand how this fits into a broader SEO strategy,
my article on
Schema Markup and SEO explains how technical details like these contribute to better search rankings.
Step 7 — Check the .htaccess File
After saving your permalink settings, WordPress writes a
.htaccess file into
your subdirectory. This file tells Apache (the web server software used by most shared hosts)
how to handle clean URLs. Open your File Manager, navigate to your subdirectory, and confirm the file exists.
Note that files starting with a dot are hidden by default — in cPanel File Manager you can
toggle visibility via the
Settings button in the top right. A correctly written
.htaccess for a subdirectory WordPress install will look
something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /shop/index.php [L]
</IfModule>
# END WordPress
The key line is
RewriteBase /shop/ — replace
shop with whatever
your actual subdirectory is called.
If WordPress generated the file but your permalinks still produce 404 errors, check that your
hosting server has
mod_rewrite enabled.
Most shared hosts have it on by default; if yours does not, raise a support ticket with them.
Important note on the main site’s .htaccess: The
.htaccess file in your
public_html root (for your main WordPress
site) should not be affected by the subdirectory install.
They are separate files in separate directories and do not overwrite each other.
Step 8 — Install a Theme and Choose Your Plugins
Your new WordPress install starts with the default Twenty Twenty-Five theme.
This subdirectory install is completely independent of your main site, so it has its own theme
and plugin library. Install whatever theme and plugins suit the purpose of this new site. Keep plugins lean. Every plugin you add is another potential performance and security liability.
Only install plugins that serve a clear function. For security hardening, a plugin like
Wordfence or Solid Security is worth adding early.
For performance, consider a caching plugin and image optimisation from the start.
Step 9 — Set Up SSL for the Subdirectory
If your main domain already has an SSL certificate (the padlock in the browser bar), the
subdirectory URL will inherit it automatically on most shared hosting setups because the
certificate covers the entire domain including subdirectories. Test this by visiting
https://yourdomain.com/shop/ with the
https:// prefix. If it loads securely, you are fine.
If you see a certificate warning, contact your hosting provider — they may need to reissue or
extend your SSL certificate to cover the path. Also make sure that WordPress is set to use
https:// in both URL fields in
Settings > General if SSL is working correctly.
Common Problems and How to Fix Them
White screen of death after installing
This almost always means a PHP error. Enable WordPress debug mode temporarily by adding
define( 'WP_DEBUG', true ); to
wp-config.php and reloading the page.
The actual error message will then appear. Common causes are incompatible plugins or a PHP
version mismatch — check your hosting panel to confirm you are running PHP 8.0 or higher.
404 error on all pages except the homepage
The
.htaccess file is missing or has incorrect
RewriteBase paths.
Re-save your permalinks from
Settings > Permalinks to regenerate it.
If that does not work, create the file manually using the template in Step 7 above.
Redirect loop
This is usually caused by mismatched values in the WordPress Address and Site Address fields,
or a conflict with an SSL redirect in your
.htaccess.
Check both URL fields in
Settings > General and make sure they include the
subdirectory in the path.
Images not loading
The media upload path is set incorrectly. Go to
Settings > Media and
check that the uploads folder path is blank (WordPress will use the default, which is correct
for a subdirectory install).
If someone previously hardcoded an absolute path here, clear it.
Using a One-Click Installer Instead
Many hosting control panels include a one-click WordPress installer such as Softaculous or
Installatron. These tools can install WordPress into a subdirectory automatically — you simply
type the subdirectory path into the installation form during setup. One-click installers are convenient and avoid manual database setup errors.
However, understanding the manual process (as covered in this guide) gives you much better
control when things go wrong, and things do go wrong from time to time.
When Would You Actually Use a Subdirectory WordPress Install?
Here are the most common real-world use cases:
- Staging environment: Install WordPress at
yourdomain.com/staging to test design changes or plugin updates before pushing them to the live site. - WooCommerce store: Keep a content-heavy main site separate from a product
catalogue at
yourdomain.com/shop. - Blog on a non-WordPress main site: If your main site is built on a
different platform, you can still run a WordPress blog at
yourdomain.com/blog. - Multi-language sites: Some businesses run a separate WordPress install
per language region, e.g.
yourdomain.com/de or yourdomain.com/fr. - Client demo site: Build a client’s new site in a hidden subdirectory
for review before going live.
If your project involves a tourism or hospitality business, a separate booking or information
site in a subdirectory can be a smart way to keep things organised.
I have built and managed a number of tourism sites over the years —
you can read more about my
tourism website design services if that is the direction you are heading.
What About WordPress Multisite?
WordPress Multisite is a different beast. It allows you to run multiple sites from a single
WordPress installation, managed from one admin network dashboard. Subdirectory installs and
Multisite often get confused with each other, but they are not the same thing. Multisite is powerful but adds complexity. If you need tight integration between multiple sites
and want central user management, it can make sense. For most small businesses that simply
want a second independent WordPress site on the same domain, a straightforward subdirectory
install as described here is simpler, easier to manage, and less risky.
Final Checklist Before Going Live
- WordPress core, themes, and plugins are all up to date
- Both WordPress Address and Site Address show the correct subdirectory URL with
https:// - Permalinks are saved and working — no 404 errors on inner pages
- SSL certificate is active and no mixed content warnings in the browser console
- An admin user has been created with a strong password (and “admin” as a username has been deleted or never used)
- A caching plugin and a security plugin have been installed and configured
- A backup solution is in place — either through your hosting panel or a plugin like UpdraftPlus
- Search engine visibility is switched on in Settings > Reading (uncheck “Discourage search engines”)
Need Help With Your WordPress Setup?
If this process sounds like more than you want to take on yourself, that is completely
understandable. Setting up WordPress correctly — especially when multiple installs are involved
— takes time and a bit of technical confidence. I offer professional WordPress setup, hosting, and ongoing management from Protaras, Cyprus,
for clients locally and internationally.
Whether you need a brand new site built, an existing one fixed, or a subdirectory install
configured properly,
get in touch and let’s discuss what you need . You might also find these related articles useful: