There was a problem loading the comments.

How to Move WordPress From Root Directory to Subdirectory?

Support Portal  »  Knowledgebase  »  Viewing Article

  Print

Sometimes, you may want to install WordPress in a subdirectory (e.g., /mywebsite) instead of the root (wwwroot/public_html), while still serving your site from the root domain (e.g., http://example.com).

 

 

This helps you keep the root directory clean without cluttering it with WordPress files.

 

👉 Example: Install WordPress in example.com/mywebsite, but access the site at http://example.com.

Here’s how you can achieve this:


✅ Step 1: Create a Subdirectory

Create the folder where you want WordPress installed.
For this tutorial, we’ll use:

 
/mywebsite

✅ Step 2: Update WordPress Settings

Go to your WordPress DashboardSettingsGeneral.Update the following:

 

💾 Save changes.


a29b38d69dee1f868886d1a1f37946ad2df83386?t=5b672b6ac49564ef92d9f8515b4d72f6

 

✅ Step 3: Move WordPress Files

Move your WordPress core files to the new subdirectory (/mywebsite).


✅ Step 4: Copy Index & .htaccess Files

  • Copy (do not move) index.php and .htaccess from /mywebsite to your root (wwwroot/public_html).

  • If you are on Windows hosting, move web.config instead of copying.

📌 Note: .htaccess is hidden. Enable “show hidden files” in FTP or cPanel File Manager.


✅ Step 5: Edit index.php

Open the index.php file in your root folder and find this line:

<div style="text-align:center; margin:20px 0;"> <pre style="display:inline-block; background:#f4f4f4; padding:12px 18px; border-radius:6px; font-size:14px; border:1px solid #ddd;"> require( dirname( __FILE__ ) . '/wp-blog-header.php' ); </pre> </div>

Replace it with this (update with your subdirectory name):

<div style="text-align:center; margin:20px 0;"> <pre style="display:inline-block; background:#f4f4f4; padding:12px 18px; border-radius:6px; font-size:14px; border:1px solid #ddd;"> require( dirname( __FILE__ ) . '/mywebsite/wp-blog-header.php' ); </pre> </div>


🎯 Final Notes

    • Your WordPress is now installed in /mywebsite but served from http://example.com.

    • Keep your root clean while still running WordPress from the subdirectory.

    • Always clear cache and reset permalinks after making these changes.


Share via
Did you find this article useful?  

Related Articles

Tags

© Softsys Hosting