Beginner's Guide for WordPress / Start your WordPress Blog in minutes

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

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 (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 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:

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 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:

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

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.

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.

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

73 CommentsLeave a Reply

  1. Hello, this steps are self explanatory but in my case, our main website doesn’t run on WordPress however we want to run WordPress on a sub-directory /blog.
    How do we go about this
    the main website runs on NodeJs

    • You should still be able to follow the steps in this guide for what you’re wanting to do.

      Admin

  2. Today I’ve set up my new WordPress inside sub-directory. Didn’t need to change the .htaccess file. I think WP is so smart now that can handle this automatically.

    • Thanks for sharing, your hosting provider may have also set it up for you when installing as certain hosts set that up for you now. :)

      Admin

  3. Thank you for this guide.

    We are planning to have subdirectories on our next website. This guide really cleared the air.

    One question though,

    Is there a limited to how many subdirectories a WordPress website can have?

  4. Hi.. thanks for this article… am unable to upload the folders wp-admin, wp-content and wp-includes in the sub directory… rest other files are uploaded.. how do I upload all of these???

    • It would depend on why you are unable, if you reach out to your hosting provider they should be able to assist but it may be a permissions issue with your user.

      Admin

  5. Thanks it worked.
    Is it possible to the subdirectory name on the URL, for example example.com/seo/how-to-rank to example.com/how-to-rank

    • If you would like your URLs not to have the subdirectory in the URL we would recommend installing the site on your primary domain rather than creating redirects to remove it from the URL.

      Admin

  6. Thanks for this article. It is very insightful.
    Will the installation of WordPress on the sub folder affect the overall speed of the site.

  7. there is an apparent error in your htaccess code example

    should be
    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /your-subdirectory/
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /your-subdirectory/index.php [L]

     
    # END WordPress

    note rewriterule line 5 change

    • Thank you for catching that, while not specifically required, we’ll look to update the article :)

      Admin

  8. I want to build a web with a wordpress subdirectory, the first web is domain.com, and the second web is domain.com/blog … as far as I know wordpress uses domain.com/blog as the default post … will it hurt SEO?

    • WordPress does not use /blog as a default, that is only the most common URL to use. Using blog for a subdirectory should not have a major effect on SEO.

      Admin

  9. is it necessary to install and manage same plugins separately if I installed wordpress on main domain and sub directory each and manage wordpress sites separately ?

  10. Hello Sir, Can I create Subdirectory without login Cpanel. I forgot My Hosting Details. But I have WP details, is it possible to create subdirectory using wordpress any plugin or other way?

    • You would need access to your hosting, you should be able to reach out to your hosting provider for assistance in being able to log back into your account.

      Admin

  11. Hi, I would like to ask is it possible to copy all the file from my current folder to the sub directory? Because I want to have the same template and plugin for my sub directory site.

  12. What if the I created a new subdirectory from another subdirectory, should the fix permalink still be relevant and work with no problem?
    For example, I have firstwebsite.com/firstsubdir/ the second subdirectory will be firstwebsite.com/firstsubdir/secsubdir/ should I still use the same fix for the permalink?

    Sorry English is not my first language.

    • You would need to include the second subdirectory in the permalink change and it should still work.

      Admin

  13. Thanks for a clear tutorial.

    Is it possible to install WP in a subdirectory but use the main domain URL to access it and still have the main URL displayed in the browser address bar?
    To clarify:
    I would install WP in mydomain.com/sub/ but would like to access it by opening mydomain.com and have mydomain.com displayed in the browser so that visitors can bookmark my URL.

    Is it possible to set it up?

    • It is possible but would depend on your hosting provider to see if it is allowed. If you reach out to your hosting provider they should be able to assist.

      Admin

        • Where your site is installed on your host shouldn’t affect your site’s loading time to a noticeable degree

  14. Salam, I just finished reading the article and i have question, how can i have the same header and footer from the wordpress installation in parent directory? I’ll be glad and thankful to you if you give me a clue, Thanks…

    • For that, the simplest method would be to install the same theme on both sites.

      Admin

  15. Really helpful! One question please.

    Do I have to add this line:

    RewriteBase /your-subdirectory/

    for every install in a sub directory in main WordPress installation?

    Thanks

  16. Hi. I manually copied my WordPress files to the root folder, without the plugin. I then copied the original database in a new one, where I replaced the siteurl to reflect the new location, the root folder. In the wp-config file at the root folder, I changed WP_HOME and WP_SITEURL to remove the /wordpress.

    As a result, I was able to reach the wp-login for my new location, but no further.

    And when I visited my site, I was getting a warning “too many redirections”.

    Any advice?

  17. Thanks a lot for WP subfolders step by step guide. One thing that i never undersatnd is how to create a exact Google news xml sitemap in WordPress?

    • Most SEO plugins should add the required markup for you to be able to be added to Google News. If you are using an SEO plugin you would want to reach out to the plugin’s support for what they recommend for setttings.

      Admin

  18. Thanks for your article. I have a question about transforming this sub domain or sub directory installed word press to main root of website and replace it with the main site. what should I do?

  19. Hi Team, Thanks for this post, not only these… all the other posts in your blog are very helpful to us, I really appreciate your works. Thanks a lot for these.

    And need a little help, actually did the same as in this post, installed wordpress in a sub directory, but I’m face a little issue, i.e. I’m unable to receive the emails from contact form, when it was on sub-domain it’s working fine, but when it is installed on sub-directory not receiving the form submissions, it’s going on loading but not getting submitted. Please help me with this. Thank you.

  20. Thanks for the info. I read every post you write.

    Just I’ve a doubt. I created a new WP Install trough my Host provider, but searching, there is no .htaccess file in the subdirectory. It’s mandatory to have a new .htaccess file? it’s going to create errors in the future?

    • WordPress should generate the htaccess file if you resave your permalinks. If you still don’t see it you may not have the option to show hidden files enabled :)

      Admin

  21. Hello, I successfully installed WordPress in a subdirectory around 3 weeks ago, I already uploaded a theme, some plugins and made some posts. Question, can I change the name of my subdirectory? How? the name is Chose for my subdirectory and what shows after my original website URL is español, I want to make it es, I want to change this because I read somewhere that characters like ñ might cause some issues in terms of SEO….so now I’m worried, thank you for your time

  22. Hey, I just followed the process except i haven’t changed the htaccess file. My site is still working properly. I am using hostinger.

    is changing the htaccess mandatory ? will it cause error in the future?

    • Your host may have set up the redirect for you, if you reach out to your host they should be able to let you know.

      Admin

  23. Just got it to work but little bit worried, does it increases my load time of both pages. I mean to say that

    ( currently I have made this on localhost for test but I am going to implement it in one or two days on my main server )

    I have two website but single domain

    Just want to know that does this will increase the bandwidth useage and load time.

    Let’s suppose if I my main webpage size 1 mb and my second website size is also 1 mb so when someone load the main page does it loads all the 1+1 2mb size.

    • Hi Owaiz,

      Yes it will increase bandwidth usage depending on your traffic. Since both WordPress installs share the resources, traffic load on one website will affect the performance of other website as well.

      Admin

  24. Hello, I dont understand something. What is the difference between installing wordpress in a subdirectory and just creating multiple pages???

    I am a noob

  25. I think I did everything as shown in your instructions. But the trouble I’m having is when I’m trying to customize my theme on the subdirectory it taking me to the root domain wp customizer. What should I do then… ?

  26. Hello, can you help me?

    I installed my local wordpress to the subdir with ftp but the problem is the css doesn’t work properly, and i don’t know what’s wrong with my wordpress, because i follow this step.
    Maybe Anyone can help?

    Thank you

  27. Hi,

    I am following the steps that you have recommended in creating the sub directory, but than I see the following error,

    When I trying to open the URL after uploading all the files to the folder through FTP,
    I see the URL redirecting to wp-admin/setup-config.php & throwing an server error 500 (This page isn’t working
    simplyrent.in is currently unable to handle this request.
    HTTP ERROR 500)

  28. I have heard that subdirectories are treated as part of root domain in terms of ranking.But my subdirectory is not ranking, even for exact match keyword search.I have indexed Subdirectory using Fetch as Google Tool.I don’t know what is the problem?

    I have submitted it to Search Console, Created separate robot.txt and sitemap (Sitemap is pending from last two days).

    Should I give more time to Google to Crawl by Subdirectory?

    Please Replay.
    Thanks!

    • Hi Jyotishman,

      It is up to search engines to decide how they would rank your website in their results. All you can do is optimize your website for SEO and follow the best practices.

      Admin

  29. Thank you for this tutorial. It saved me after hours trying to understand why I was getting 404 errors all day long.

  30. Question: Login for main and subdirectory

    Hi. I created a subdirectory with a separate WP install.
    It looks like the user has to create an account for the main and subdirectory and to login for both the main and subdirectory.

    Is there a way to let a user who has login to either the main or subdirectory site to have access to the other site without having to login again? i.e if user has login into main site, he/she does not need to login to the subdirectory site. and vice versa.

    Thanks.

    TH

  31. By default, if you are using softaculous, you are installing wordpress to the default directory named wp. You don’t need to install manually WordPress in a directory/ subdomain, you only need to change the name of the directory where you want Softaculous to install WordPress and it will also make a database and so on. :)

  32. Thanks for this tutorial.
    It would be interesting to show, when you have a little time of course, how to configure cPanel redirects to this subdirectory. For example, I can’t redirect my domain name to a WordPress subdirectory créé sous /public-html.

Leave a Reply to Jyotishman Nath Cancel 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.